构造函数和类型绑定过程的Doxygen问题

时间:2017-11-18 22:22:02

标签: parameters constructor fortran comments doxygen

我想用doxygen评论我的Fortran代码,发现有两个官方文档来源:

我试图根据这些来评论我的代码,但我收到以下警告:

/home/martin/4Neuro/src/Connection.f08:36: warning: argument 'added_value' of command @param is not found in the argument list of connection_mod::connection::adjust_weight()
Generating docs for compound connection_mod::intervalconnection...
/home/martin/4Neuro/src/Connection.f08:132: warning: Member new_interval_connection(input_neuron, output_neuron, weight) (function) of class connection_mod::intervalconnection is not documented.

如何正确评论added_value类型绑定过程的参数adjust_weight,如何评论模块过程new_interval_connection

我的代码

    module Connection_mod
    implicit none

    public

    ! TODO smazat
    type :: Neuron
        real :: state

        contains
            procedure :: get_state => get_state_impl
            procedure :: set_state => set_state_impl
    end type Neuron

    !------------------!------------------------------------------------------------------------
    ! Type definitions !
    !------------------!

    !> Represents a connection between two neurons.
    type, abstract :: Connection
        private 

        class(Neuron), pointer :: input_neuron   !< Pointer to an input neuron
        class(Neuron), pointer :: output_neuron  !< Pointer to an output neuron
        real                   :: weight         !< Weight of the connection

        contains

            !> Initializes the common Connection class components
            !! 'input_neuron', 'output_neuron' and 'weight'.
            !! I.e. serves similarly to an abstract constructor.
            procedure :: init_components   => init_components_impl

            !> Adds a given value to the current weight of the  
            !! connection.
            !! @param added_value Number (real) to be added to the current weight
            procedure :: adjust_weight     => adjust_weight_impl

            !> Getter for the private 'input_neuron' component
            !! @return Pointer to the input neuron (type Neuron, pointer)
            procedure :: get_input_neuron  => get_input_neuron_impl

            !> Getter for the private 'output_neuron' component
            !! @return Pointer to the output neuron (type Neuron, pointer)
            procedure :: get_output_neuron => get_output_neuron_impl

            !> Getter for the private 'weight' component
            !! @return Weight of the connection (type real)
            procedure :: get_weight        => get_weight_impl

    end type Connection

    !> Represents a connection between two neurons.
    !! Able to pass a signal from an input neuron to 
    !! an output one.
    type, extends(Connection) :: IntervalConnection
       contains

          !> Passes (assigns) the product 
          !! input neuron state * weight)
          !! to an output neuron.
          procedure :: pass_signal => pass_signal_impl
    end type IntervalConnection

    !------------!------------------------------------------------------------------------------
    ! Interfaces !
    !------------!
    interface IntervalConnection
        !> Constructor of IntervalConnection class
        module procedure :: new_interval_connection
    end interface IntervalConnection

    contains
    !------------------------!------------------------------------------------------------------
    ! Method implementations !
    ! -----------------------!

        !--------------!
        ! class Neuron !
        !--------------!
        ! TODO smazat
        function get_state_impl(this) result(state)
            class(Neuron), intent(in) :: this
            real                      :: state

            state = this%state
        end function get_state_impl

        ! TODO smazat
        subroutine set_state_impl(this, new_state)
            class(Neuron), target  :: this
            real, intent(in)       :: new_state

            this%state = new_state
        end subroutine set_state_impl

        !------------------!
        ! class Connection !
        !------------------!
        subroutine init_components_impl(this, input_neuron, output_neuron, weight) 
            class(Connection), intent(inout) :: this
            type(Neuron), pointer     :: input_neuron
            type(Neuron), pointer     :: output_neuron
            real, intent(in)          :: weight

            this%input_neuron  => input_neuron
            this%output_neuron => output_neuron
            this%weight        = weight
        end subroutine init_components_impl

        subroutine adjust_weight_impl(this, added_value)
            class(Connection), intent(inout) :: this
            real, intent(in)                 :: added_value

            this%weight = this%weight + added_value
        end subroutine adjust_weight_impl

        !--------------------------!
        ! class IntervalConnection !
        !--------------------------!
        subroutine pass_signal_impl(this)
            class(IntervalConnection), intent(in) :: this

            call this%output_neuron%set_state(this%input_neuron%get_state() * this%weight)
        end subroutine pass_signal_impl

        !--------------!------------------------------------------------------------------------
        ! Constructors !
        !--------------!
        function new_interval_connection(input_neuron, output_neuron, weight) result(ret_obj)
            type(Neuron), pointer             :: input_neuron
            type(Neuron), pointer             :: output_neuron
            real, intent(in)                  :: weight
            type(IntervalConnection), pointer :: ret_obj

            allocate(ret_obj)

            call ret_obj%init_components(input_neuron, output_neuron, weight)
        end function new_interval_connection

        !-------------------!-------------------------------------------------------------------
        ! Getters & Setters !
        !-------------------!

        !> asdf
        !! aaaa
        function get_input_neuron_impl(this) result (input_neuron)
            class(Connection), target, intent(in) :: this
            class(Neuron), pointer                :: input_neuron

            input_neuron => this%input_neuron
        end function get_input_neuron_impl

        function get_output_neuron_impl(this) result (output_neuron)
            class(Connection), target, intent(in) :: this
            class(Neuron), pointer                :: output_neuron

            output_neuron => this%output_neuron
        end function get_output_neuron_impl

        function get_weight_impl(this) result (weight)
            class(Connection), intent(in) :: this
            real                          :: weight

            weight = this%weight
        end function get_weight_impl

end module Connection_mod

1 个答案:

答案 0 :(得分:0)

过程参数的文档注释应该是过程的文档注释(不是绑定)的一部分,或者参数本身的文档。我更喜欢后者,因为那时你不需要@param指令。

程序被记录为模块的成员,您可能还需要为模块提供文档注释,以便包含该过程的模块出现在doxygen导航中。

!> Stuff for connections.
module Connection_mod
...

  subroutine adjust_weight_impl(this, added_value)
    class(Connection), intent(inout) :: this
    !> added_value Number (real) to be added to the current weight
    real, intent(in)                 :: added_value