def test_extensions(tempdir): qs.main(['-q', '-p', 'project_name', '-a', 'author', '--extensions', 'foo,bar,baz', tempdir]) conffile = tempdir / 'conf.py' assert conffile.isfile() ns = {} execfile_(conffile, ns) assert ns['extensions'] == ['foo', 'bar', 'baz']
def test_extensions(tempdir): qs.main(['-q', '-p', 'project_name', '-a', 'author', '--extensions', 'foo,bar,baz', tempdir]) conffile = tempdir / 'conf.py' assert conffile.isfile() ns = {} execfile_(conffile, ns) assert ns['extensions'] == ['foo', 'bar', 'baz']
readmePath = os.path.join(path, 'README.md') if os.path.exists(readmePath): with open(readmePath) as r: projectREADME = r.read() try: projectTitle = re.findall('^#([^#\n]+)', projectREADME)[0] except BaseException: projectTitle = path else: projectREADME = "" projectTitle = path quickstart.main([ '-q', '--project={}'.format(projectTitle), '--author={}'.format(author), '--no-makefile', '--sep', '--template={}\sphinxTemplate'.format(sphinxResource), out ]) indexPath = os.path.join(out, 'source', 'index.rst') _defaultIndex = os.path.join(out, 'source', '_defaultIndex.rst') batchPath = os.path.join(out, 'make.bat') with open(batchPath, 'w+') as batch: batch.write('python -m SASDocumentation "{}" "{}"'.format( os.path.abspath(path), os.path.abspath(out))) if not os.path.exists(_defaultIndex): with open(indexPath) as i: defaultIndex = i.read() with open(_defaultIndex, 'w') as di:
"-p", PACKAGE_NAME, "-a", AUTHOR, # "--makefile", "--batchfile", "--ext-autodoc", "--ext-imgmath", "--ext-viewcode", "--ext-githubpages", "-d", "version=" + VERSION, "-d", "release=" + VERSION, OUT_DIR ] sphinx_quickstart.main(argv=quickstart_argv) # Since some parameters are sadly hardcoded, it follows some dirty editing: conf_py = os.path.join(OUT_DIR, "conf.py") with open(conf_py, "r+") as f: # open in read/write mode: lines = f.readlines() os.remove(conf_py) # remove line, append text at beginning and at end: try: lines.pop(lines.index(REMOVE_LINE)) except ValueError: print("WARNING: EXPECTED LINE DIDN'T EXIST:", REMOVE_LINE) lines.insert(1, EXTRA_BEGIN + "\n") lines.append(EXTRA_END + "\n") # rewrite edited file to its original path with open(conf_py, "w") as f:
# -*- coding: utf-8 -*- import re import sys from sphinx.cmd.quickstart import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(main())
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Sphinx - Python documentation toolchain ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ import sys if __name__ == '__main__': from sphinx.cmd.quickstart import main sys.exit(main(sys.argv[1:]))