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

Ford 7.0.1: AttributeError: 'str' object has no attribute 'name' #583

Closed JulesKouatchou closed 10 months ago

JulesKouatchou commented 10 months ago

I am using Ford 7.0.1 to generate a documentation for a large application. Every time I run Ford, I have the same error message (see below) on different files at different directories. However, when gather only the individual files (where Ford is failing within the application) in a separate project, Ford runs without any issue. I am little bit confused.

Any help or pointer will be appreciated. If needed, I can provide a large tarball.

Thank you for your assistance.

Jules


Error Message

  Correlating information from different parts of your project...Traceback (most recent call last):
  File "/usr/local/bin/ford", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/usr/local/Cellar/ford/7.0.1/libexec/lib/python3.11/site-packages/ford/__init__.py", line 491, in run
    main(proj_data, proj_docs)
  File "/usr/local/Cellar/ford/7.0.1/libexec/lib/python3.11/site-packages/ford/__init__.py", line 419, in main
    project.correlate()
  File "/usr/local/Cellar/ford/7.0.1/libexec/lib/python3.11/site-packages/ford/fortran_project.py", line 336, in correlate
    container.correlate(self)
  File "/usr/local/Cellar/ford/7.0.1/libexec/lib/python3.11/site-packages/ford/sourceform.py", line 1296, in correlate
    entity.correlate(project)
  File "/usr/local/Cellar/ford/7.0.1/libexec/lib/python3.11/site-packages/ford/sourceform.py", line 1261, in correlate
    item = self._find_chain_item(call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/ford/7.0.1/libexec/lib/python3.11/site-packages/ford/sourceform.py", line 1491, in _find_chain_item
    return get_label_item(context, call_chain[-1])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/ford/7.0.1/libexec/lib/python3.11/site-packages/ford/sourceform.py", line 1453, in get_label_item
    labels[extend_type.name.lower()] = extend_type
           ^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'name'
ZedThree commented 10 months ago

Hi @JulesKouatchou, this looks like the same bug as reported here -- should be fixed in 7.0.2. Please could you try updating Ford and let me know if it still persists?

JulesKouatchou commented 10 months ago

Thank you for your suggestion. I installed Ford 7.0.2 and attempted to generate the documentation again. There was progress but had another error (similar to the original one?):

  Correlating information from different parts of your project...
Traceback (most recent call last):
  File "/Users/jkouatch/miniconda/23.5.2-0_py3.11/2023-09-28/bin/ford", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/Users/jkouatch/miniconda/23.5.2-0_py3.11/2023-09-28/lib/python3.11/site-packages/ford/__init__.py", line 491, in run
    main(proj_data, proj_docs)
  File "/Users/jkouatch/miniconda/23.5.2-0_py3.11/2023-09-28/lib/python3.11/site-packages/ford/__init__.py", line 419, in main
    project.correlate()
  File "/Users/jkouatch/miniconda/23.5.2-0_py3.11/2023-09-28/lib/python3.11/site-packages/ford/fortran_project.py", line 338, in correlate
    container.correlate(self)
  File "/Users/jkouatch/miniconda/23.5.2-0_py3.11/2023-09-28/lib/python3.11/site-packages/ford/sourceform.py", line 1296, in correlate
    entity.correlate(project)
  File "/Users/jkouatch/miniconda/23.5.2-0_py3.11/2023-09-28/lib/python3.11/site-packages/ford/sourceform.py", line 1261, in correlate
    item = self._find_chain_item(call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jkouatch/miniconda/23.5.2-0_py3.11/2023-09-28/lib/python3.11/site-packages/ford/sourceform.py", line 1484, in _find_chain_item
    context = item.parent.all_types.get(type_str, None)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ExternalType' object has no attribute 'all_types'
ZedThree commented 10 months ago

@JulesKouatchou Please could you try #584 and let me know if that fixes it?

JulesKouatchou commented 10 months ago

@ZedThree I looked at #584 as you suggested. Is there any new version of Ford that has the fix? Thanks.

ZedThree commented 10 months ago

Not yet, you'd have to checkout the branch locally and try that.

If you can come up with a minimal, self-contained example that has the bug, I can test it myself.

JulesKouatchou commented 10 months ago

@ZedThree Thank you for the branch you created. I got it and installed Ford but it did not resolve the issue.

I created a tarball (big) here:

  https://drive.google.com/file/d/1opQF8zFl--nlsi7TW_ImqNAQihQEGwtP/view?usp=sharing

When you gunzip the file, you will get the folder MAPL/. To generate the documentation, go to the folder:

       MAPL/docs/Ford/

and issue the command:

       ford docs-with-remote-esmf.md

You may want to edit the preprocessor setting in docs-with-remote-esmf.md.

Thank you for your assistance.

Cheers,

Jules

ZedThree commented 10 months ago

Thanks @JulesKouatchou, that's allowed me to track it down and check the fix.

I think there's a better fix, but I don't have time to implement it right now, so I'll make an issue and hopefully be able to resolve it properly in the future

ZedThree commented 10 months ago

@JulesKouatchou I've released 7.0.3 with this fix in now

JulesKouatchou commented 10 months ago

@ZedThree Thank you very much. With 7.0.3, I no longer have an issue. I appreciate your effort in fixing issues.

amorison commented 10 months ago

Could you reopen the issue? It is still present 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

ZedThree commented 10 months ago

@amorison That looks like a different issue, just a similar exception. I'll open a separate issue for it