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

Implement reStructuredText generation for online documentation of GDExtensions #10733

Closed
Ivorforce opened this issue Sep 13, 2024 · 6 comments
Closed

Comments

@Ivorforce
Copy link
Member

Ivorforce commented Sep 13, 2024

Describe the project you are working on

A gdextension.

Describe the problem or limitation you are having in your project

GDExtensions cannot currently generate online documentation akin to the godot docs. An online reference is an important alternative to in-editor documentation, especially before installation.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

GDExtensions should be able to generate online-compatible documentation, much like make rst for the godot engine itself.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

godot-cpp has recently acquired the capability to generate ingame docs files (doc_classes xml files), thanks to dsnopek. It should be possible to adapt some more of the godot engine documentation pipeline to generate rst files, that can be adapted by e.g. Sphinx to be hosted on a site.

I will be playing with the tool soon, especially as it tool may already support foreign docs to some capacity. If so, it could be integrated and / or its use documented for gdextensions that want to host documentation online.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not really, though you could manually set up sphinx, duplicating your documentation.

Is there a reason why this should be core and not an add-on in the asset library?

Docs are an important part of complex libraries, useful to all gdextensions.

@dsnopek
Copy link

dsnopek commented Sep 13, 2024

This draft PR may also be interesting to you - it aims to put inline Doxygen comments in godot-cpp itself, so your IDE can help give you documentation: godotengine/godot-cpp#1311

@Ivorforce
Copy link
Member Author

I came across the PR as I was researching for this. It would be an excellent addition, though it's orthogonal to what I propose here.

@Ivorforce Ivorforce changed the title Implement online documentation generation for gdextensions. Implement rst generation for gdextension online documentation. Sep 13, 2024
@dalexeev
Copy link
Member

make_rst.py only reads XML files, so you can probably run it against GDExtension docs too.

@Ivorforce
Copy link
Member Author

Ivorforce commented Sep 15, 2024

I tested make_rst.py. It complains a ton (because of unresolved godot types), and I had to add a version.py file to my own project to make it happy, but it does spit out correct looking .rst files. From here to sphinx docs should be pretty easy.

The approach, outlined

I think an easy first step should be to add an option to the script to ignore unresolved references. The best way to use it without cloning the repo may be the way poetry handles their installer:

curl -sSL https://raw.githubusercontent.com/godotengine/godot/master/doc/tools/make_rst.py | python3 - -o "doc/classes" -l "en" doc_classes

Finally, we'll need to add documentation for how to gdextensions should use the tool, including a section for a minimal sphinx (or similar) setup.

I don't think any of this will be a big burden to the existing tooling, so I'll just go forward prepare PRs in the next 1-2 weeks.

@Ivorforce
Copy link
Member Author

Ivorforce commented Sep 16, 2024

I was able to build the docs into a readthedocs repo, mirroring the one godot uses: https://numdot.readthedocs.io/en/latest/index.html

To achieve this:

  • Create docs/
  • Add godot-docs as a submodule
  • Copy over and modify conf.py, index.rst and .readthedocs.yaml, as well as a few assets.
  • Build class references from .xml files with curl -sSL https://raw.githubusercontent.com/godotengine/godot/master/doc/tools/make_rst.py | python3 - -o "doc/classes" -l "en" doc_classes
  • Create a readthedocs account, add the project and build it.

For anyone coming across here looking to create docs for their own gdextension, feel free to use my implementation as a template: https://github.com/Ivorforce/NumDot/tree/main/docs

I will consolidate this information into a wiki page to the gdextension docs page. It would be nice to have a 'simpler' way for adding docs without depending on the full godot docs repo, but for now this is an acceptable workflow.

@Calinou Calinou changed the title Implement rst generation for gdextension online documentation. Implement reStructuredText generation for online documentation of GDExtensions Sep 18, 2024
@Ivorforce
Copy link
Member Author

Ivorforce commented Sep 19, 2024

As godotengine/godot-docs#9966 is merged, the scope of this proposal will be fulfilled: Generating online documentation from the ingame documentation (.xml files) is now a treaded and loosely documented path. With this, I'll close this proposal.

To view the docs entry on the matter, visit the article GDExtension Docs System (the changes should be viewable soon).

The outlined workflow could certainly be better, but it could also be a lot worse. Any improvements to it should be separately proposed.

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

No branches or pull requests

4 participants