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

Fix bug with hide_undoc = True #651

Merged

Conversation

thundermoose
Copy link
Contributor

The hide_undoc flag didn't work correctly. When running FORD on a project with the hide_undoc flag set to true, FORD crashes with the following traceback:

Traceback (most recent call last):
  File "/home/thundermoose/ExternalGits/ford/ford.py", line 7, in <module>
    run()
  File "/home/thundermoose/ExternalGits/ford/ford/__init__.py", line 489, in run
    main(proj_data, proj_docs)
  File "/home/thundermoose/ExternalGits/ford/ford/__init__.py", line 420, in main
    project.correlate()
  File "/home/thundermoose/ExternalGits/ford/ford/fortran_project.py", line 343, in correlate
    container.prune()
  File "/home/thundermoose/ExternalGits/ford/ford/sourceform.py", line 1415, in prune
    self.functions = self.filter_display(self.functions)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thundermoose/ExternalGits/ford/ford/sourceform.py", line 615, in filter_display
    return [obj for obj in collection if self._should_display(obj)]
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/thundermoose/ExternalGits/ford/ford/sourceform.py", line 608, in _should_display
    if self.settings.hide_undoc and not item.doc:
                                        ^^^^^^^^
AttributeError: 'FortranFunction' object has no attribute 'doc'

The reason this happen is that the project.correlate() function is called before the project.markdown(md) line where the doc attributes are setup. Switching order of these lines is not possible since the markdown parser md depend on project.correlate(). The solution was simple, check if the doc_list attribute is non-empty instead of checking for the doc attribute. Perhaps I should check if the items in the doc_list are not empty strings as well?

@ZedThree
Copy link
Member

ZedThree commented Jul 4, 2024

Thank you for finding and fixing this @thundermoose! Sorry for the delay in getting around to looking at it. I've added a test and simplified the check a bit.

@ZedThree ZedThree changed the title hide_undoc bug seem to have been resolved Fix bug with hide_undoc = True Jul 4, 2024
@ZedThree ZedThree merged commit 4944f06 into Fortran-FOSS-Programmers:master Jul 4, 2024
5 checks passed
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 this pull request may close these issues.

2 participants