Skip to content

Commit

Permalink
Fix docs build on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chrahunt committed Dec 28, 2019
1 parent 4d1fd08 commit c9ab34a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions docs/html/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,26 @@
)
]


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('-', ' ')
)
Expand Down

0 comments on commit c9ab34a

Please sign in to comment.