From d0e014b4bcf6b39bb7ba915a95204ae2371e6f0f Mon Sep 17 00:00:00 2001 From: Harumi Kuno Date: Sun, 5 Sep 2021 17:42:03 -0700 Subject: [PATCH] Omit NAME section if blank description 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 --- doc/usage/configuration.rst | 2 ++ sphinx/writers/manpage.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 0ae9cd5df..fecbe0bfe 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -2331,6 +2331,8 @@ These options influence manual page output. *description* Description of the manual page. This is used in the NAME section. + Can be an empty string if you do not want to automatically generate + the NAME section. *authors* A list of strings with authors, or a single string. Can be an empty diff --git a/sphinx/writers/manpage.py b/sphinx/writers/manpage.py index 29d93aa84..12fc31281 100644 --- a/sphinx/writers/manpage.py +++ b/sphinx/writers/manpage.py @@ -112,10 +112,10 @@ class ManualPageTranslator(SphinxTranslator, BaseTranslator): # overwritten -- added quotes around all .TH arguments def header(self) -> str: tmpl = (".TH \"%(title_upper)s\" \"%(manual_section)s\"" - " \"%(date)s\" \"%(version)s\" \"%(manual_group)s\"\n" - ".SH NAME\n") + " \"%(date)s\" \"%(version)s\" \"%(manual_group)s\"\n") if self._docinfo['subtitle']: - tmpl += "%(title)s \\- %(subtitle)s\n" + tmpl += (".SH NAME\n" + "%(title)s \\- %(subtitle)s\n") return tmpl % self._docinfo def visit_start_of_file(self, node: Element) -> None: