Skip to content

Doxygen/znai integration - #35

Merged
Bronek merged 35 commits into
mainfrom
feature/doxygen
Jul 23, 2024
Merged

Bronek merged 35 commits into
mainfrom
feature/doxygen

Conversation

@godexsoft

Copy link
Copy Markdown
Collaborator

Ok, so this is heavily WIP stuff of course.

To try this you will need a few things:

  • Add doxygen to your dev container (Dockerfile)
  • Enable DOCS option in cmake (-DDOCS=ON or through VSCode CMake Cache editor UI)
  • Build the docs target
  • Install znai (brew install testingisdocumenting/brew/znai on mac. If you are on Linux - bad luck, you are on your own :rage4:)

The above steps should generate build/xml doxygen output.
You can now try znai like so znai --preview --port 3333 from the docs folder. 3333 can be replaced with your favourite port number. You can then navigate to 127.0.0.1:3333 to see the generated website. You can tweak things inside docs folder and znai will reload automatically.

Comment thread docs/reference-manual/api-reference.md Resolved
Comment thread docs/file-name.js Resolved
@codecov

codecov Bot commented Feb 22, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.0%. Comparing base (6dee9c9) to head (e51eb02).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #35   +/-   ##
=======================================
  Coverage   100.0%   100.0%           
=======================================
  Files          20       20           
  Lines         857      859    +2     
  Branches      121      121           
=======================================
+ Hits          857      859    +2     
Files Coverage Δ
include/functional/and_then.hpp 100.0% <ø> (ø)
include/functional/choice.hpp 100.0% <ø> (ø)
include/functional/fail.hpp 100.0% <ø> (ø)
include/functional/filter.hpp 100.0% <100.0%> (ø)
include/functional/functor.hpp 100.0% <ø> (ø)
include/functional/inspect.hpp 100.0% <ø> (ø)
include/functional/inspect_error.hpp 100.0% <ø> (ø)
include/functional/or_else.hpp 100.0% <ø> (ø)
include/functional/pack.hpp 100.0% <ø> (ø)
include/functional/recover.hpp 100.0% <ø> (ø)
... and 4 more

Impacted file tree graph

Comment thread docs/snippets/filter/expected_error.cpp Resolved
Comment thread docs/doxygen.json Resolved
Comment thread cmake/Docs.cmake Resolved
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./.build/docs

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MykolaGolubyev I have added the deploy step here, it's uploading correctly to gh-pages but there is a catch, we specify functional as the doc-id when exporting the docs and so they end up in build/docs/functional. Once i upload with gh-pages, you can see the result on https://libfn.org/functional

This is almost good but i'd like the functional docs to be at the root of libfn.org. Is that something we can do with Znai today? The problem is that znai generates all the internal links/paths as /functional/... so i can't simply put the exported pages to the root of libfn.org.
I could not find any options on Znai that would allow me to easily fix it. Please let me know if there are any 🙇‍♂️

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right. One way to "improve" it a bit is to use docs as docId (e.g. https://liftwizard.io/docs/configuration/json5-configuration)

But also wonder (haven't tried) if you pass an empty string or maybe forward slash as docId.

The reason for docId internal requirement is so urls can be treated the same way /docs/my-page and /docs/my-page/ (extra slash). Otherwise relative linking (..) would be messed up.

If you go with docs then you can imagine having blog or something like that. Not ideal trade off I understand.

Let me know if empty docId doesn't work and I will check the code to make it work.

@godexsoft godexsoft Mar 18, 2024 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestions. Trying now.

  • If i specify empty ('') or a space ( ) for doc-id, then i get Missing argument for option: doc-id
  • Completely removing -doc-id automatically sets the doc-id to no-id-specified which also is not root
  • Specifying a forward slash (/) yields an exception:
    generating the rest of HTML pages
    deploying index.md to /index.html
    Exception in thread "main" java.lang.RuntimeException: error during rendering of index: java.nio.file.AccessDeniedException: /index.html
    

Looks like this use-case is just not supported atm.
Perhaps it will be easy to fix. I like the forward slash idea. I feel like it's almost working except for the permissions 🤞

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for the docs and blog idea - that's not too bad if we ever have a blog.
But for now, I'd like Znai to have the ability to generate straight for the root path. I think this is likely going to be a common use case.. I fear it's only time before other users come with the same question to you :rage4:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please try to remove doc-id parameter altogether?

This does not appear to work. It creates the no-id-specified folder on export then.

Feel free to provide more feedback so I can pack them all together for the next release

Sorry, did not find the time to write more documentation yet. So i don't really have feedback outside of what we covered before in the discussion on this pr. 🙇

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix was released as 1.69

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have switched to the new version and it seems to do the right thing now 👍 🙇

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if you have docs deployed somewhere - I could take a look and maybe suggest a thing or two if you want.
If you have some energy left, could you please post something here - testingisdocumenting/znai#824

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MykolaGolubyev latest docs are deployed to libfn.org but we are yet to actually write the contents :rage4:

@Bronek Bronek added the documentation Improvements or additions to documentation label Apr 17, 2024

---

<!--

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MykolaGolubyev 👋
I tried to add some more stubs today and ran into this error.
Not sure what's going on here. Hope you can shed some light on this.

FWIW i can see fn::pack in the generated doxygen XML. Any pointers are welcome 🙇

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the error message?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only difference i can see in terms of doxygen XML is that fn::pack got multiple members that have the same name. Maybe some issue with that?

 332   │   <compound refid="structfn_1_1pack" kind="struct"><name>fn::pack</name>
 333   │     <member refid="structfn_1_1pack_1a1cd01f467210d1d7c92970b2ac9710e6" kind="typedef"><name>_impl</name></member>
 334   │     <member refid="structfn_1_1pack_1a6b53a6941902d275f05b8f8c5958a413" kind="typedef"><name>append_type</name></member>
 335   │     <member refid="structfn_1_1pack_1a5220de4d35d50f54338debe93b10b849" kind="function"><name>append</name></member>
 336   │     <member refid="structfn_1_1pack_1a53d43b92cdf165cb2d8067b0c629058f" kind="function"><name>append</name></member>
 337   │     <member refid="structfn_1_1pack_1a6d0c972a2291e4847df68664b2c26550" kind="function"><name>append</name></member>
 338   │     <member refid="structfn_1_1pack_1ab91b4d2c1b74c153c82986fd87395908" kind="function"><name>append</name></member>
 339   │     <member refid="structfn_1_1pack_1a9e45953a7b8f6963ba6d0441c4c92098" kind="function"><name>append</name></member>
 340   │     <member refid="structfn_1_1pack_1a9e613c892d2c3f5fb01716b5ec6cad46" kind="function"><name>append</name></member>
 341   │     <member refid="structfn_1_1pack_1a76399fca98d2deadfe412506e672b550" kind="function"><name>append</name></member>
 342   │     <member refid="structfn_1_1pack_1a54b1422d57f8881d34f9dd0dc34b2a06" kind="function"><name>append</name></member>
 343   │     <member refid="structfn_1_1pack_1a71cecf0ac11f392300b0e1f429fc4ff4" kind="function"><name>invoke</name></member>
 344   │     <member refid="structfn_1_1pack_1a1c02cb92af7c4b414e386139a3ed16b2" kind="function"><name>invoke</name></member>
 345   │     <member refid="structfn_1_1pack_1ae8ea2c2693c675bfafda5c93f38b0c9b" kind="function"><name>invoke</name></member>
 346   │     <member refid="structfn_1_1pack_1a944f830f292b349d5576f64247becfa7" kind="function"><name>invoke</name></member>
 347   │     <member refid="structfn_1_1pack_1a86f6e65efd32c44fb4f6658b67023e90" kind="function"><name>invoke_r</name></member>
 348   │     <member refid="structfn_1_1pack_1a0e70b046265c82ff71799a363700c5df" kind="function"><name>invoke_r</name></member>
 349   │     <member refid="structfn_1_1pack_1aa1416546a44ade53d09e240c7d9f3f1c" kind="function"><name>invoke_r</name></member>
 350   │     <member refid="structfn_1_1pack_1a845b8cb7987cc4bc407082ba74a4537a" kind="function"><name>invoke_r</name></member>
 351   │   </compound>
 352   │   <compound refid="structfn_1_1detail_1_1pack__impl" kind="struct"><name>fn::detail::pack_impl</name>
 353   │   </compound>

The error from znai is in the source file where this comment is pointing.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying the error out for visibility:

Exception in thread "main" java.lang.RuntimeException: 
markup parsing error:
    TOC item: reference-manual/pack
    full path: /Users/godexsoft/Development/functional/docs/reference-manual/pack.md
error handling include plugin <doxygen-doc>
  free param: fn::pack
  opts: {}
expected to find element <declname>
        at org.testingisdocumenting.znai.website.WebSite.throwParsingErrorMessage(WebSite.java:570)
        at org.testingisdocumenting.znai.website.WebSite.parseMarkupAndUpdateTocItemAndSearch(WebSite.java:562)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
        at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1117)
        at org.testingisdocumenting.znai.website.WebSite.parseMarkups(WebSite.java:501)
        at org.testingisdocumenting.znai.website.WebSite.parse(WebSite.java:193)
        at org.testingisdocumenting.znai.website.WebSite.parseAndDeploy(WebSite.java:179)
        at org.testingisdocumenting.znai.website.WebSite$Configuration.deployTo(WebSite.java:1034)
        at org.testingisdocumenting.znai.cli.ZnaiCliApp.generateDocs(ZnaiCliApp.java:197)
        at org.testingisdocumenting.znai.cli.ZnaiCliApp.start(ZnaiCliApp.java:99)
        at org.testingisdocumenting.znai.cli.ZnaiCliApp.start(ZnaiCliApp.java:70)
        at org.testingisdocumenting.znai.cli.ZnaiCliApp.main(ZnaiCliApp.java:75)
Caused by: java.lang.RuntimeException: error handling include plugin <doxygen-doc>
  free param: fn::pack
  opts: {}
expected to find element <declname>
        at org.testingisdocumenting.znai.parser.commonmark.MarkdownVisitor.handleIncludePlugin(MarkdownVisitor.java:232)
        at org.testingisdocumenting.znai.parser.commonmark.MarkdownVisitor.visit(MarkdownVisitor.java:155)
        at znaishaded.org.commonmark.node.CustomBlock.accept(CustomBlock.java:7)
        at znaishaded.org.commonmark.node.AbstractVisitor.visitChildren(AbstractVisitor.java:137)
        at znaishaded.org.commonmark.node.AbstractVisitor.visit(AbstractVisitor.java:28)
        at znaishaded.org.commonmark.node.Document.accept(Document.java:7)
        at org.testingisdocumenting.znai.parser.commonmark.MarkdownParser.parsePartial(MarkdownParser.java:98)
        at org.testingisdocumenting.znai.parser.commonmark.MarkdownParser.parse(MarkdownParser.java:66)
        at org.testingisdocumenting.znai.website.WebSite.parseMarkupAndUpdateTocItemAndSearch(WebSite.java:549)
        ... 10 more
Caused by: java.lang.IllegalArgumentException: expected to find element <declname>
        at org.testingisdocumenting.znai.utils.XmlUtils.lambda$nextLevelNodeByName$1(XmlUtils.java:87)
        at java.base/java.util.Optional.orElseThrow(Optional.java:403)
        at org.testingisdocumenting.znai.utils.XmlUtils.nextLevelNodeByName(XmlUtils.java:87)
        at org.testingisdocumenting.znai.doxygen.parser.DoxygenMemberParser.lambda$parseMember$0(DoxygenMemberParser.java:63)
        at java.base/java.util.stream.SpinedBuffer$1Splitr.forEachRemaining(SpinedBuffer.java:364)
        at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:782)
        at org.testingisdocumenting.znai.doxygen.parser.DoxygenMemberParser.parseMember(DoxygenMemberParser.java:62)
        at org.testingisdocumenting.znai.doxygen.parser.DoxygenMemberParser.parseXml(DoxygenMemberParser.java:44)
        at org.testingisdocumenting.znai.doxygen.parser.DoxygenMemberParser.parse(DoxygenMemberParser.java:38)
        at org.testingisdocumenting.znai.doxygen.parser.DoxygenCompoundParser.parseMember(DoxygenCompoundParser.java:66)
        at java.base/java.util.stream.SpinedBuffer$1Splitr.forEachRemaining(SpinedBuffer.java:356)
        at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:782)
        at org.testingisdocumenting.znai.doxygen.parser.DoxygenCompoundParser.parseXml(DoxygenCompoundParser.java:62)
        at org.testingisdocumenting.znai.doxygen.parser.DoxygenCompoundParser.parse(DoxygenCompoundParser.java:39)
        at org.testingisdocumenting.znai.doxygen.Doxygen.findAndParseCompound(Doxygen.java:136)
        at org.testingisdocumenting.znai.doxygen.Doxygen.getCachedOrFindAndParseCompound(Doxygen.java:101)
        at org.testingisdocumenting.znai.doxygen.plugin.DoxygenDocIncludePlugin.process(DoxygenDocIncludePlugin.java:58)
        at org.testingisdocumenting.znai.extensions.TrackingIncludePlugin.process(TrackingIncludePlugin.java:65)
        at org.testingisdocumenting.znai.parser.commonmark.MarkdownVisitor.handleIncludePlugin(MarkdownVisitor.java:228)
        ... 18 more

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to reproduce and believe the problem is that znai expects declname for every argument:

        <param>
          <type>std::in_place_type_t&lt; T &gt;</type>
        </param>
        <param>
          <type>auto &amp;&amp;...</type>
          <declname>args</declname>
        </param>

As a temporary workaround (if possible) a to change signature so that Doxygen generates declname.
Longer term, do you have a preference what to use as a default?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any progress with this issue @MykolaGolubyev ?
The tmp workaround of course works but i don't think anyone would want to sacrifice code for docs so better support for unnamed arguments is very much desired! 🙇‍♂️

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reminding. Will allocate some time this week.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.70 is released

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for letting me know 🙇 Will try as soon as i can.

Comment thread docs/meta.json
{
"title": "Functional",
"type": "Library",
"support": {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MykolaGolubyev originally i had viewOn here and i'd keep it if there is a way to disable it on some pages. For example, i don't want this link on the landing index.md page but i'd like to have it for all the files inside of reference-manual. Is there a way to do this? I could not find it. Thanks

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just in case - viewOn should point to original md file that is the source for the page.
What makes you want to hide it for some pages?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It generates urls automatically.. for the index.md it generates url//index. instead of url/index.md. If all urls would be correct, maybe i'd keep viewOn as is

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like a bug! could you please submit another issue?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bronek Bronek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just please avoid copying code into documentation.

Comment thread docs/snippets/and_then/choice_value.cpp Outdated
CHECK(parse("2e9") == fn::choice(2e9));
CHECK(parse("5e9") == fn::choice(5e9));
CHECK(parse("foo").has_value(std::in_place_type<std::nullopt_t>));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not copy code excerpts like this into documentation; they can easily become obsolete. Instead do try to refer to existing code in unit tests - tests/examples is made for this. Ideally if Znai supported some form of code referral syntax, so you just put some kind of a comment inside e.g. tests/examples/simple.cpp. It's fine (a good practice even) to add more files to tests/examples specifically for this purpose.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, Znai definitely got some support for it. I will try and use it 👍

Comment thread docs/toc
index
sum
index

No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this structure (might not like it later in the life of the project, but today it's great)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, you can always adjust it later (or i will on your request).

@godexsoft
godexsoft marked this pull request as ready for review July 3, 2024 06:57
@Bronek
Bronek merged commit f6277e0 into main Jul 23, 2024
@Bronek
Bronek deleted the feature/doxygen branch October 12, 2024 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants