tomtom-international / asciidoxy

AsciiDoxy generates API documentation from Doxygen XML output to AsciiDoc.
Apache License 2.0
31 stars 10 forks source link

Asciidoxy treats cmake source code as though it was asciidoxy directives #74

Open mkschreder opened 1 year ago

mkschreder commented 1 year ago

The following code generates error:

[source,cmake]
----
some_cmake_code(${CMAKE_VARIABLE})
----
ERROR: Error while processing AsciiDoc files:
Undefined
Traceback:
  File index.adoc, line 16, in AsciiDoc
    ${include("document.adoc", leveloffset="+1")}
  File document.adoc, line 7, in AsciiDoc
    ${include("document.adoc")}
  File document.adoc, line 96, in AsciiDoc
    some_cmake_stuff(${CMAKE_VARIABLE}) <- this is problematic

Asciidoxy also seems to ignore asciidoc comments where even lines prefixed with "//" are still processed.

This is a bug since:

  1. source blocks must not be treated as asciidoxy code
  2. Comment blocks must not be expanded as asciidoxy directives
silvester747 commented 1 year ago

Sorry for the late response. This is currently a limitation of AsciiDoxy. It is however possible to suppress the parsing as directives:

[source,cmake]
----
${"""
some_cmake_code(${CMAKE_VARIABLE})
"""}
----

See also: https://asciidoxy.org/getting-started/using-python.html#_comments

But I will see if there is something I can do to improve this.

silvester747 commented 1 year ago

I have been thinking about this. My main challenge is that sometimes you may want to be able to execute python code to populate the example. E.g. in the AsciiDoxy documentation I use it to include the output of asciidoxy -h in the generated documentation.

But maybe I can improve the way AsciiDoxy handles it. Either by somehow ignoring it if fails to parse, or by giving a more clear error message with a recommendation on how to escape the code.

mkschreder commented 1 year ago

I think the proper way would be to simply ignore it inside code blocks. Code blocks are after all expected to be treated as preformatted literals so I thimk they should never be modified.