Fortran-FOSS-Programmers / ford

Automatically generates FORtran Documentation from comments within the code.
https://forddocs.readthedocs.io
GNU General Public License v3.0
405 stars 131 forks source link

Exception when resolving links in docstrings of deferred bound methods #591

Closed ZedThree closed 10 months ago

ZedThree commented 10 months ago

[Issue] when resolving links in the docstring of deferred bound methods. For example:

module hello_mod
    implicit none

    private

    type, public, abstract :: foo_t
        contains
        !> See [[bar]] for more information
        procedure(foo_iface), public, deferred :: foo
    end type

    abstract interface
        subroutine foo_iface(self)
            import :: foo_t
            class(foo_t), intent(in) :: self
        end subroutine
    end interface

    public bar

contains

    !> More details about [[foo_t]] API
    subroutine bar
    end subroutine
end module

leads to:

Attribute error

```text Parsing files ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 1/1 0:00:00 0:00:00 ../src/hello.f90 Correlating information from different parts of your project... ...done in 0.000s ⠋ Processing comments ━━━━━━━━━━━━━━━━━━━━╺━━━━━━━━━━━━━━━━━━━ 50% 4/8 0:00:01 0:00:00 foo Traceback (most recent call last): File "/home/adrien/.pyenv/versions/3.11.4/bin/ford", line 8, in sys.exit(run()) ^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/ford/__init__.py", line 491, in run main(proj_data, proj_docs) File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/ford/__init__.py", line 446, in main project.markdown(md, base_url) File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/ford/fortran_project.py", line 403, in markdown item.markdown(md) File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/ford/sourceform.py", line 405, in markdown self.doc = md.reset().convert( ^^^^^^^^^^^^^^^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/ford/_markdown.py", line 119, in convert return super().convert(source) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/markdown/core.py", line 258, in convert newRoot = treeprocessor.run(root) ^^^^^^^^^^^^^^^^^^^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/markdown/treeprocessors.py", line 367, in run self.__handleInline(text), child ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/markdown/treeprocessors.py", line 127, in __handleInline data, matched, startIndex = self.__applyPattern( ^^^^^^^^^^^^^^^^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/markdown/treeprocessors.py", line 268, in __applyPattern node, start, end = pattern.handleMatch(match, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/ford/_markdown.py", line 236, in handleMatch return self.convert_link(m), m.start(0), m.end(0) ^^^^^^^^^^^^^^^^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/ford/_markdown.py", line 201, in convert_link item = find_child(context) ^^^^^^^^^^^^^^^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/ford/_markdown.py", line 198, in find_child return context.find_child(name, m["entity"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/ford/sourceform.py", line 583, in find_child return _find_in_list(collection, name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/adrien/.pyenv/versions/3.11.4/lib/python3.11/site-packages/ford/sourceform.py", line 108, in _find_in_list if name == item.name.lower(): ^^^^^^^^^ AttributeError: 'str' object has no attribute 'name' ```

Here is a mwe for convenience:

ford_name_resol_test.tar.gz

Originally posted by @amorison in https://github.com/Fortran-FOSS-Programmers/ford/issues/583#issuecomment-1806824756

amorison commented 10 months ago

I confirm that this solves the issue, thanks!