Skip to content
Snippets Groups Projects
Commit cb5a91a1 authored by Studer Gabriel's avatar Studer Gabriel
Browse files

fix doc generation

- os.path.walk does not exist in Python3 anymore, use os.walk instead
  (changed interface)
- sphinx-build tried really hard to use Python 2. Import sphinx from
  current interpreter instead and directly call its __main__ function
parent 6a3ee355
No related branches found
No related tags found
No related merge requests found
...@@ -5,18 +5,13 @@ import shutil ...@@ -5,18 +5,13 @@ import shutil
from ost import settings from ost import settings
from optparse import OptionParser from optparse import OptionParser
import subprocess import subprocess
import sphinx
if len(sys.argv)==2: if len(sys.argv)==2:
root_dir=sys.argv[1] root_dir=sys.argv[1]
else: else:
root_dir='.' root_dir='.'
def _CheckCall(cmd, shell):
r = subprocess.call(cmd, shell=True)
if r != 0:
sys.stderr.write("Command '%s' returned non-zero exit status %d\n"%(cmd, r))
sys.exit(-1)
def _OutputPath(inpath, outdir): def _OutputPath(inpath, outdir):
parts=inpath.split(os.path.sep) parts=inpath.split(os.path.sep)
filtered_parts=[outdir] filtered_parts=[outdir]
...@@ -71,7 +66,6 @@ def _CollectRstDocs(outdir, dirname, fnames): ...@@ -71,7 +66,6 @@ def _CollectRstDocs(outdir, dirname, fnames):
img_name = os.path.join(dirname,img) img_name = os.path.join(dirname,img)
_CreateAndCopy(img_name, outdir) _CreateAndCopy(img_name, outdir)
def ParseArgs(): def ParseArgs():
parser = OptionParser("usage: ost make.py [options] ") parser = OptionParser("usage: ost make.py [options] ")
parser.add_option("-l","--linkcheck", action="store_true", default=False, dest="linkcheck", help="validate all external links") parser.add_option("-l","--linkcheck", action="store_true", default=False, dest="linkcheck", help="validate all external links")
...@@ -93,25 +87,19 @@ if opts.quiet: ...@@ -93,25 +87,19 @@ if opts.quiet:
opt_str=' -Q ' opt_str=' -Q '
for sub_dir in ('modules',): for sub_dir in ('modules',):
os.path.walk(sub_dir, _CollectRstDocs, 'doc/source') print("start walking")
sphinx_bin=settings.Locate(['sphinx-build', 'sphinx-build-2.6','sphinx-build-2.7']) for directory, dirnames, filenames in os.walk(sub_dir):
_CollectRstDocs('doc/source', directory, filenames)
if opts.html: if opts.html:
cmd='%s %s -b html -c %s %s %s' % (sphinx_bin, opt_str, sphinx.main([opt_str, '-b', 'html', '-c', 'doc/conf', 'doc/source', 'doc/build/html'])
'doc/conf', 'doc/source', 'doc/build/html')
print(cmd)
_CheckCall(cmd, shell=True)
if opts.doctest: if opts.doctest:
cmd='%s %s -b doctest -c %s %s %s' % (sphinx_bin, opt_str, sphinx.main([opt_str, '-b', 'doctest', '-c', 'doc/conf', 'doc/source', 'doc/build/html'])
'doc/conf', 'doc/source',
'doc/build/doctest')
_CheckCall(cmd, shell=True)
if opts.build_json: if opts.build_json:
cmd='%s %s -b json -c %s %s %s' % (sphinx_bin, opt_str, 'doc/conf', sphinx.main([opt_str, '-b', 'json', '-c', 'doc/conf', 'doc/source', 'doc/build/html'])
'doc/source', 'doc/build/json')
_CheckCall(cmd, shell=True)
if opts.linkcheck: if opts.linkcheck:
cmd='%s %s -b linkcheck -c %s %s %s' % (sphinx_bin, opt_str, 'doc/conf', sphinx.main([opt_str, '-b', 'linkcheck', '-c', 'doc/conf', 'doc/source', 'doc/build/html'])
'doc/source', 'doc/build/check')
_CheckCall(cmd, shell=True)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment