Fix docs build on Windows

Sphinx expects the "document name" field to be normalized with respect
to slashes (all /), so we now do this in a portable way for Windows.
This commit is contained in:
Chris Hunt 2019-12-28 18:21:46 -05:00
parent 4d1fd08d45
commit c9ab34a945
1 changed files with 12 additions and 3 deletions

View File

@ -273,17 +273,26 @@ man_pages = [
)
]
def to_document_name(path, base_dir):
"""Convert a provided path to a Sphinx "document name".
"""
relative_path = os.path.relpath(path, base_dir)
root, _ = os.path.splitext(relative_path)
return root.replace(os.sep, '/')
# Here, we crawl the entire man/commands/ directory and list every file with
# appropriate name and details
man_dir = os.path.join(docs_dir, 'man/')
man_dir = os.path.join(docs_dir, 'man')
raw_subcommands = glob.glob(os.path.join(man_dir, 'commands/*.rst'))
if not raw_subcommands:
raise FileNotFoundError(
'The individual subcommand manpages could not be found!'
)
for fname in raw_subcommands:
fname_base = fname[len(man_dir):-4]
outname = 'pip-' + fname_base[9:]
fname_base = to_document_name(fname, man_dir)
outname = 'pip-' + fname_base.split('/')[1]
description = u'description of {} command'.format(
outname.replace('-', ' ')
)