Skip to content

Use more sphinx extensions in the documentation #4743

Closed

Description

@seisman

Description of the desired feature

The GMT documentation is built by Sphinx with the theme sphinx_rtd_theme and a few sphinx extensions.

Currently, the source codes of the theme sphinx_rtd_theme and the extensions are included in the GMT repository (https://github.com/GenericMappingTools/gmt/tree/master/doc/rst/themes/rtd and https://github.com/GenericMappingTools/gmt/tree/master/doc/rst/_extensions). With the theme and extensions included, anyone can build the GMT documentation without installing extra dependencies, except sphinx.

Recently, I find some sphinx extensions which may be useful in the GMT documentation:

  • sphinx-copybutton: add a little “copy” button to the right of code blocks so that readers can easily copy the codes
  • sphinx-panels: provide some useful directives. For example, the panels directive can be used to design a better landing page.
Current (a waste of space) Expected (better)
image image

the dropdown directive (see the screenshot below) can be used to add examples to show the usage of specific options, without making the manpage too long (the examples are collapsed by default).
image
We already have a solution to add inline examples, but the code is difficult to read and maintain. For example, we have an example for plot -L option, and the raw codes are crazy:
image

Another similar extension is sphinx-togglebutton.

Hopefully, you all agree that these extensions can help improve the readability of the GMT documentation.

However, these extensions (and most other sphinx extensions) usually have several source code files (in Python or CSS), and it's difficult to include them in the GMT repository (it's possible but a little difficult to maintain). I think the best way is to install them before building documentation, e.g.:

pip install sphinx-copybutton sphinx-panels sphinx-togglebutton

but it means that anyone who wants to build the documentation must install the python packages by themselves. It would be a little difficult for non-python users, but perhaps still acceptable for GMT developers?

Edit: we decided to include these extensions in the GMT repository.

Activity

  1. added
    feature request
    on Feb 4, 2021
  2. changed the title [-]Use more sphinx extensions in the documentations[/-] [+]Use more sphinx extensions in the documentation[/+] on Feb 4, 2021
  3. PaulWessel commented on Feb 4, 2021

    @PaulWessel
    Contributor

    This looks very promising for both the panels directive and the togglebutton. To add simple, working examples for many options will be quite a bit of work, of course. I wonder if it may be a small step in the right direction to at least have a link from such options to an example that we already have, to at least demonstrate how a particular option is used in a command. Would the toglebutton open up access to a command that users can copy/paste into terminal to run? Should there be a figure as well? Maybe we need a template for this first, so that they all are very similar, e.g.,example code, figure result, link to more reading?

  4. added
    documentation
    on Feb 23, 2021
  5. maxrjones commented on Mar 7, 2021

    @maxrjones
    Member

    @seisman, I am interested in trying out the dropdown directive for the figures in cookbook/features.rst. Would this overlap with anything you are working on/plan to work on?

  6. seisman commented on Mar 7, 2021

    @seisman
    MemberAuthor

    @seisman, I am interested in trying out the dropdown directive for the figures in cookbook/features.rst. Would this overlap with anything you are working on/plan to work on?

    No, feel free to try it. Good to have a PR using the dropdown directive to compare with the PR #4926 which used a new extension.

  7. maxrjones commented on Mar 9, 2021

    @maxrjones
    Member

    What do you think of the autosectionlabel extension? It seems like it could be really helpful for the cookbook.

  8. seisman commented on Mar 10, 2021

    @seisman
    MemberAuthor

    It looks useful.

  9. maxrjones commented on Mar 10, 2021

    @maxrjones
    Member

    It looks useful.

    Nevermind. It leads to hundreds of duplicate label warnings, so won't work easily for the GMT docs.

  10. seisman commented on Mar 10, 2021

    @seisman
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationfeature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions