ecmwf-ifs / ectrans

Global spherical harmonics transforms library underpinning the IFS
Apache License 2.0
17 stars 33 forks source link

ecTrans documentation #113

Open samhatfield opened 3 months ago

samhatfield commented 3 months ago

ecTrans currently has no documentation beyond the relevant chapter of the IFS documentation. An open-source project ought to have at least instructions for building and running the code and a documentation of the API (in this case the routines in src/trans/external.

I propose to use mkdocs to build a basic documentation site using Markdown. This will use the Readthedocs theme as that's what everyone is used to, but there are other themes available.

mkdocs allows you to build a static site with minimal overhead. Just a mkdocs.yml file and some markdown files. I like it because all of the static site plumbing can be kept out of the main ecTrans repository. For now someone could build the documentation locally and upload it to a sites.ecmwf.int, but in future we could find a way to do this automatically with a Github action.

I suggest sections of

See samhatfield/docs for an idea of how this looks.

And the site itself:

Screenshot 2024-07-08 at 14 29 08

Screenshot 2024-07-08 at 14 29 16

Any thoughts @wdeconinck @marsdeno @ioanhadade @reuterbal?

reuterbal commented 2 months ago

Fully supportive of this idea!

I like the use of a readthedocs theme, which is in line with what we use elsewhere. Some of these documentations are made available directly on readthedocs.io, but we have also the option to use https://sites.ecmwf.int/docs, where for example Loki and Atlas documentation is hosted. I believe we have examples for both what the Github actions setup needs to look like to automatically update this.

Just two things I'd throw in to consider:

  1. Please include a contributing section in the readme (which is embarrisingly empty right now) that mentions explicitly the requirement to sign a CLA. See for example the relevant section in the ecwam readme: https://github.com/ecmwf-ifs/ecwam?tab=readme-ov-file#contributing
  2. In my experience, the API documentation is almost guaranteed to be out of sync most of the time if it isn't auto-generated from the Fortran. I think Ford and Doxygen have this ability but don't necessarily integrate flawlessly with mkdocs. But they have also other advantages such as dependency graph visualisation, which might make them worthwile investigating at least?
samhatfield commented 2 months ago
  1. Sure, good point.
  2. Yes I'm a big fan of Ford. My issue with Ford in this case is that it doesn't distinguish between the external (which is what most people will care about) and internal routines. As a result the Ford page is a bit overwhelming for a first-time user. I think the best approach is just to have both. If we could somehow parse the include files (setup_trans0.h etc.) to automatically generate Markdown docblocks that render to what you see above, that would be really cool.
samhatfield commented 2 months ago

Turns out Ford supports arbitrary Markdown-based static sites. So I was able to add my own User Guide section! Pretty cool. Let's go with Ford then.

Screenshot 2024-07-09 at 13 34 08

samhatfield commented 2 months ago

Docs now live at https://sites.ecmwf.int/docs/ectrans/.

wdeconinck commented 2 months ago

That's super nice Sam, especially as the previous FORD documention is no longer auto-generated within ifs-source. The special API documentation is nice but would be cool if it could be autogenerated from in-code documentation of just the interface header files, which we can extend.

We may want to filter out the transi sources from this FORD documentation. It has its own doxygen (see https://github.com/ecmwf-ifs/ectrans/blob/main/src/transi/transi.h) Could you also add support to generate the doxygen for transi and add it to the domain, e.g. https://sites.ecmwf.int/docs/ectrans/transi and put a link in the FORD documentation?

samhatfield commented 2 months ago

We could certainly find a way to automatically extract the docblock from each of the header files and stitch them together. I'll add that to the TODO list.

And adding a separate build step for the transi Doxygen, good idea :)