Skip to content

Commit

Permalink
Add man_skip_desc_subtitle
Browse files Browse the repository at this point in the history
A configuration value to optionally skip printing the description
of a command as a subtitle when generating a manpage.
This commit addresses issue sphinx-doc#9430

Signed-off-by: Harumi Kuno <harumi.kuno@hpe.com>
  • Loading branch information
hkuno committed Jul 11, 2021
1 parent 904f896 commit 81826b7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions doc/usage/configuration.rst
Expand Up @@ -402,6 +402,11 @@ General configuration

.. versionadded:: 1.7

.. confval:: man_skip_desc_subtitle

If true, do not print out description as a subtitle in man page
documents. Default is ``False``.

.. confval:: nitpicky

If true, Sphinx will warn about *all* references where the target cannot be
Expand Down
4 changes: 4 additions & 0 deletions sphinx/cmd/build.py
Expand Up @@ -179,6 +179,10 @@ def get_parser() -> argparse.ArgumentParser:
const='no',
help=__('do not emit colored output (default: '
'auto-detect)'))
group.add_argument('-S', '--skip-subtitle', dest='skipsubtitle', action='store_const',
const='yes', default='no',
help=__('Skip subtitle (default: '
'auto-detect)'))
group.add_argument('-w', metavar='FILE', dest='warnfile',
help=__('write warnings (and errors) to given file'))
group.add_argument('-W', action='store_true', dest='warningiserror',
Expand Down
1 change: 1 addition & 0 deletions sphinx/config.py
Expand Up @@ -129,6 +129,7 @@ class Config:
'needs_sphinx': (None, None, [str]),
'needs_extensions': ({}, None, []),
'manpages_url': (None, 'env', []),
'man_skip_desc_subtitle': (False, 'env', []),
'nitpicky': (False, None, []),
'nitpick_ignore': ([], None, []),
'nitpick_ignore_regex': ([], None, []),
Expand Down
5 changes: 3 additions & 2 deletions sphinx/writers/manpage.py
Expand Up @@ -113,8 +113,9 @@ def __init__(self, document: nodes.document, builder: Builder) -> None:
def header(self) -> str:
tmpl = (".TH \"%(title_upper)s\" \"%(manual_section)s\""
" \"%(date)s\" \"%(version)s\" \"%(manual_group)s\"\n"
".SH NAME\n"
"%(title)s \\- %(subtitle)s\n")
".SH NAME\n")
if (not self.config.man_skip_desc_subtitle):
tmpl += "%(title)s \\- %(subtitle)s\n"
return tmpl % self._docinfo

def visit_start_of_file(self, node: Element) -> None:
Expand Down

0 comments on commit 81826b7

Please sign in to comment.