ford icon indicating copy to clipboard operation
ford copied to clipboard

hide_undoc bug seem to have been resolved

Open thundermoose opened this issue 1 year ago • 0 comments
trafficstars

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?

thundermoose avatar Jun 20 '24 12:06 thundermoose