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

documentation: Consider adding reference to relevant code samples in the Doxygen documentation #60647

Closed
kartben opened this issue Jul 20, 2023 · 1 comment · Fixed by #62029
Labels

Comments

@kartben
Copy link
Collaborator

kartben commented Jul 20, 2023

Is your enhancement proposal related to a problem? Please describe.

When browsing the API documentation (or also the source code directly, frankly), it would be nice to have references to existing code samples that are relevant to such or such API, to be able to directly jump to working code that shows the API in action.

Describe the solution you'd like

Not sure about the cleanest way to implement it, but thinking a Doxygen ALIAS could do the trick.
Maybe something along the lines of:

ALIASES += "zephyrsample{2}=\xrefitem zephyrsample \"Relevant Code Samples\" \"Relevant Code Samples\" <a href=\"https://docs.zephyrproject.org/latest/samples/\1/README.html\">\2</a>"

Which could be used as follows: @zephyrsample{net/mqtt_sn_publisher, MQTT-SN Client Sample}. Two not necessarily ideal things there are:

  1. I don't think we have "https://docs.zephyrproject.org/latest/" a.k.a. documentation's base URL defined anywhere (and not sure that we want to either?), so not sure about the best way there. Guess relative URLs could be an option? On the other hand, being able to link to Zephyr's "rst" documentation from Doxygen is not necessarily a crazy thing to do, and something that people have expressed interest in -- see e.g https://discord.com/channels/720317445772017664/884782246010175528/1126434905593761802.
  2. The second argument to the alias feels like it's duplicating the name of the sample, but probably not a big deal. For folks who don't want to bother, we could also have an ALIAS that only has 1 arg and doesn't require a human-readable name.

Not sure an xrefitem is needed FWIW, it just that it gave me a quick&dirty way to test things out, and also automatically provides grouping of several occurences of zephyrsample into the same "Relevant Code Samples" header.

Note: if needed we could have the ALIAS have a different output for HTML (Doxygen HTML documentation) and XML (doc has pulled by Sphinx/Docleaf for being embedded in the main documentation).

Describe alternatives you've considered

N/A

Additional context

This feedback/RFE has been brought up by several people in the Zephyr documentation survey that was recently conducted.

Related: At some point we will probably want at doing the opposite as well, i..e make sure that .rst documentation for code samples clearly calls out which API/subsystem/whatever it is a sample for, and systematically cross-reference the couple of relevant Doxygen or Sphinx doc pages.

cc @gmarull

@kartben
Copy link
Collaborator Author

kartben commented Aug 10, 2023

Not sure how I missed it before but it could be that Doxygen's [@example](https://www.doxygen.nl/manual/commands.html#cmdexample) command would be a good solution. Need to test it to see if this actually requires documenting the samples with Doxygen or if the tool is happy if it's just used to reference "regular" files/directories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant