mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
Parse out command descriptions from files for Sphinx man pages
sphinx expects that the description for a command (as appearing in its man page) be provided in conf.py, not in the rst file itself. LLVM handles this with some custom Python code that parses it out of the file. Do the same thing in fish.
This commit is contained in:
parent
c8dc306b18
commit
fb75d0f848
1 changed files with 11 additions and 1 deletions
|
@ -144,6 +144,16 @@ latex_documents = [
|
|||
|
||||
# -- Options for manual page output ------------------------------------------
|
||||
|
||||
def get_command_description(path):
|
||||
""" Return the description for a command, by parsing its first line """
|
||||
with open(path) as fd:
|
||||
title = fd.readline()
|
||||
if ' - ' not in title:
|
||||
raise SphinxWarning('No description in file %s' % os.path.basename(path))
|
||||
_, desc = title.split(' - ', 1)
|
||||
return desc.strip()
|
||||
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
|
@ -153,7 +163,7 @@ man_pages = [
|
|||
for path in sorted(glob.glob('cmds/*')):
|
||||
docname = strip_ext(path)
|
||||
cmd = os.path.basename(docname)
|
||||
man_pages.append((docname, cmd, '', '', 1))
|
||||
man_pages.append((docname, cmd, get_command_description(path), '', 1))
|
||||
|
||||
|
||||
# -- Options for Texinfo output ----------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue