From c9ab34a9451dba538ef0cc68a2724052beddc1a2 Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Sat, 28 Dec 2019 18:21:46 -0500 Subject: [PATCH] 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. --- docs/html/conf.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/html/conf.py b/docs/html/conf.py index bb30f75fb05..aae7ab12df1 100644 --- a/docs/html/conf.py +++ b/docs/html/conf.py @@ -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('-', ' ') )