Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Derived type extension of an abstract derived type #504

Open
patflynngithub opened this issue Apr 9, 2023 · 3 comments
Open

Derived type extension of an abstract derived type #504

patflynngithub opened this issue Apr 9, 2023 · 3 comments

Comments

@patflynngithub
Copy link

patflynngithub commented Apr 9, 2023

I have a "concrete" derived type extension of an abstract derived type. The "after contains (module level)" part of the concrete procedure and its autodoc comments don't display in the FORD-generated doc; the abstract procedure does. Neither appear on the Procedures webpage.
FORD version: 6.2.4

abstract_mod.F90

!> mod_abstract module
module mod_abstract

implicit none

! ---------------------------------------------------------------

!> Abstract derived type
type, abstract, public :: abstract_t

contains

   procedure(output_int_abs), deferred :: output_int  !! procedure in abstract derived type

end type abstract_t

! ------------------------

!> abstract interface
abstract interface

   !> subroutine in abstract interface
   subroutine output_int_abs(this, an_int)
      import abstract_t
      implicit none
      class(abstract_t), intent(in)  :: this
      integer,           intent(in)  :: an_int  !! dummy variable declaration in abstract interface
   end subroutine output_int_abs

end interface

end module mod_abstract

concrete_mod.F90

!> mod_concrete module
module mod_concrete

use mod_abstract, only :  abstract_t

implicit none

!> concrete_t derived type
type, extends(abstract_t), public :: concrete_t

contains

   !> procedure in concrete_t derived type
   procedure output_int

end type concrete_t

contains

!> subroutine output_int in concrete_t
subroutine output_int(this, an_int)

   implicit none

   class(concrete_t), intent(in)  :: this
   integer,           intent(in)  :: an_int     !! dummy variable declaration in concrete_t

   write (*,*) "an_int = ", an_int

end subroutine output_int

end module mod_concrete
@patflynngithub
Copy link
Author

As to why this is an issue for me. I give two reasons. I've used concrete/abstract classes in creating a library for internal use in my organization.

  1. It's most natural to put autodoc comments on the concrete procedures rather than the abstract ones because many developers in my organization, while knowing Fortran, will not be familiar with abstract classes in Fortran; they might be confused by them.
  2. The library was designed to support multiple underlying scientific databases, which is why the concrete/abstract class structure was used. The resulting different concrete class extensions of the abstract class will, of course, share the same functionality, so having autodoc comments on the abstract procedure makes sense for this. However, there can be slight differences between the concrete procedure versions that need to be autodoc commented. It's natural to put these comments on the concrete procedures.

@patflynngithub
Copy link
Author

I could autodoc comment the procedure entries inside the concrete derived type definition, but there are many such procedures and would make the derived type definition excessively "busy." It would make it difficult to quickly glance at the derived type definition in order to see what type-bound procedures are available.

@ZedThree
Copy link
Member

ZedThree commented May 5, 2023

Please could you post your Ford config file? I'm not sure I can reproduce your issue. Using this minimal config file:

---
project: Example Project
src_dir: ./src
output_dir: ./doc
---

and your files:

.
├── example-project-file.md
└── src
    ├── abstract_mod.f90
    └── concrete_mod.f90

I see the concrete output_int on the procedures page:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants