CMakePP / CMinx

Generates API documentation for CMake functions and macros
https://cmakepp.github.io/CMinx/
Apache License 2.0
14 stars 5 forks source link

[BUG] Cminx fails with `AttributeError: 'filter' object has no attribute 'extend'` #143

Closed dschiller closed 1 year ago

dschiller commented 1 year ago

Describe the bug When executing cminx on the following .cmake file it fails.

test.cmake

add_test(NAME anyname)

function(myfunc paramA paramB)
endfunction()

To Reproduce Steps to reproduce the behavior:

  1. Execute cminx -o docs/cmake -r test.cmake
  2. See error
cminx -o docs/cmake -r test.cmake
2023-02-22 12:42:04,759 - cminx - INFO - Writing RST files to /Volumes/K2TB/Work/CMake/tools/develop/docs/cmake
2023-02-22 12:42:04,760 - cminx - INFO - Writing for file /Volumes/K2TB/Work/CMake/tools/develop/test.cmake
2023-02-22 12:42:04,767 - cminx.aggregator - ERROR - Caught exception while processing command beginning at line number 3
Traceback (most recent call last):
  File "/Volumes/K2TB/Work/CMake/tools/develop/.venv/bin/cminx", line 10, in <module>
    sys.exit(main())
  File "/Volumes/K2TB/Work/CMake/tools/develop/.venv/lib/python3.8/site-packages/cminx/__init__.py", line 146, in main
    document(input_file, settings_obj)
  File "/Volumes/K2TB/Work/CMake/tools/develop/.venv/lib/python3.8/site-packages/cminx/__init__.py", line 192, in document
    document_single_file(input_path, input_path, new_settings)
  File "/Volumes/K2TB/Work/CMake/tools/develop/.venv/lib/python3.8/site-packages/cminx/__init__.py", line 361, in document_single_file
    output_writer = auto_documenter.process()
  File "/Volumes/K2TB/Work/CMake/tools/develop/.venv/lib/python3.8/site-packages/cminx/documenter.py", line 91, in process
    self.walker.walk(self.aggregator, self.parser.cmake_file())
  File "/Volumes/K2TB/Work/CMake/tools/develop/.venv/lib/python3.8/site-packages/antlr4/tree/Tree.py", line 151, in walk
    self.walk(listener, child)
  File "/Volumes/K2TB/Work/Coding/CMake/tools/develop/.venv/lib/python3.8/site-packages/antlr4/tree/Tree.py", line 149, in walk
    self.enterRule(listener, t)
  File "/Volumes/K2TB/Work/Coding/CMake/tools/develop/.venv/lib/python3.8/site-packages/antlr4/tree/Tree.py", line 163, in enterRule
    ctx.enterRule(listener)
  File "/Volumes/K2TB/Work/Coding/CMake/tools/develop/.venv/lib/python3.8/site-packages/cminx/parser/CMakeParser.py", line 180, in enterRule
    listener.enterCommand_invocation(self)
  File "/Volumes/K2TB/Work/Coding/CMake/tools/develop/.venv/lib/python3.8/site-packages/cminx/aggregator.py", line 553, in enterCommand_invocation
    raise e
  File "/Volumes/K2TB/Work/Coding/CMake/tools/develop/.venv/lib/python3.8/site-packages/cminx/aggregator.py", line 536, in enterCommand_invocation
    self.documented_awaiting_function_def.params.extend(param_names)
AttributeError: 'filter' object has no attribute 'extend'

Removing

add_test(NAME anyname)

or

function(myfunc paramA paramB)
endfunction()

from test.cmake or paramB from the function signature makes cminx not fail.

Expected behavior Cminx should create the documentation.

Additional context None


cminx==1.1.0
Python 3.8.2
AutonomicPerfectionist commented 1 year ago

Hmmm Github isn't notifying me again... I believe this should be a one-line change; I seem to have accidentally copied a piece of code for processing ct_add_test() to the regular add_test() processing code