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

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

Closed
ZedThree opened this issue Nov 13, 2023 · 1 comment · Fixed by #592
Closed

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

ZedThree opened this issue Nov 13, 2023 · 1 comment · Fixed by #592

Comments

@ZedThree
Copy link
Member

ZedThree commented Nov 13, 2023

[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

  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 <module>
    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 #583 (comment)

ZedThree added a commit that referenced this issue Nov 13, 2023
This seems to happen with deferred bound procedures

Fixes #591
@amorison
Copy link

I confirm that this solves the issue, thanks!

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

Successfully merging a pull request may close this issue.

2 participants