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

let user skip printing command description #9594

Merged
merged 4 commits into from Sep 11, 2021

Conversation

hkuno
Copy link
Contributor

@hkuno hkuno commented Aug 30, 2021

Subject: let user skip printing command description

Update manpage builder to skip printing the description of a command as a subtitle if the supplied description is blank.
This commit addresses #9430

Feature or Bugfix

  • Bugfix

Purpose

Many well-established software library projects that predate RST have a large number of existing *roff-style man pages.
Such projects often have both online documentation on the web and also man pages for use on linux operating systems.
When such packages choose to switch their man pages from nroff to RST, they may want to use a single set of RST files as source to produce both their online documentation (html files) and also their linux man pages (nroff files).

However, the manpage.py builder currently always adds a subtitle with a description of the command that is provided as input to config and the html builders do not do this.

This means that the RST author currently has to produce different RST source files for the manpage and the html builders,
because if the RST file contains a description of the command then that description will appear twice in the generated man page, and if the RST file does NOT contain a description of the command, then there will be no description in the generated html file.

For example, @jsquyres and I would like to generate both groff files and also html files from a single set of rst man page files for the Open-MPI project (https://github.com/open-mpi/). Here is a simple example: https://github.com/jsquyres/ompi-sphinx-dist/blob/main/docs/src/ompi-man/man3/MPI_Abort.3.rst . Some examples of the original nroff files are here: https://github.com/open-mpi/ompi/tree/master/ompi/mpi/man/man3

If rst/conf.py contains the following:

man_pages=[("ompi/mpi/man/man3/MPI_Abort.3","MPI_Abort", "(from conf.py) Terminates MPI execution environment","",3)]

... then the generated man page will look like this:

MPI_ABORT(3)                            Open MPI                            MPI_ABORT(3)

NAME
       MPI_Abort - (from conf.py) Terminates MPI execution environment

       MPI_Abort - Terminates MPI execution environment.

SYNTAX
   C Syntax
          #include <mpi.h>
          int MPI_Abort(MPI_Comm comm, int errorcode)
...

If we omit the "MPI_Abort - Terminates MPI execution environment." line from the RST file, then the generated html page will lose that command description.

This PR would make it possible for us to use sphinx-build to produce both HTML and manpage files from a single set of RST files.

Detail

Relates

Don't print the description of a command as a subtitle
when generating a manpage if the description is empty.
This commit addresses sphinx-doc#9430

Signed-off-by: Harumi Kuno <harumi.kuno@hpe.com>
@tk0miya tk0miya added type:enhancement enhance or introduce a new feature builder:manpage labels Sep 5, 2021
@tk0miya tk0miya added this to the 4.2.0 milestone Sep 5, 2021
Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

LGTM! Could you update the document of man_page? Testcase is also needed for this.

Also, update man page for configuration to document that
if a blank description is entered, the "NAME" section is an
empty string.

Signed-off-by: Harumi Kuno <harumi.kuno@hpe.com>
@hkuno
Copy link
Contributor Author

hkuno commented Sep 6, 2021

LGTM! Could you update the document of man_page? Testcase is also needed for this.

I'll be happy to do that!
I have updated the doc/usage/configuration.rst file, which made me realize that it would be more consistent to omit the entire NAME section if the description is an empty string. Doing that matches how entering an empty string for authors omits the AUTHORS section, so I also made that change.

Regarding the testcase, do you mean add a new testcase to test_build_manpage.py?

Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

Now I added a testcase directly.

@tk0miya tk0miya merged commit 260f217 into sphinx-doc:4.x Sep 11, 2021
@tk0miya
Copy link
Member

tk0miya commented Sep 11, 2021

Merged. Thank you for your contribution!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
builder:manpage type:enhancement enhance or introduce a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants