Skip to content
Snippets Groups Projects
runsphinx.py.in 1.03 KiB
Newer Older
"""We need to run Sphinx inside MantidPlot to document the internal
   module. This script calls the sphinx entry point with the necessary
   arguments
"""
import os
def main():
    # Update environment with screenshots path
    screenshots_dir = "@SCREENSHOTS_DIR@"
    if screenshots_dir != "":
        os.environ["SCREENSHOTS_DIR"] = screenshots_dir
    builder = "@BUILDER@"
    src_dir = "@CMAKE_CURRENT_SOURCE_DIR@/source"
    sphinx_build_dir = "@SPHINX_BUILD_DIR@"
    output_dir = os.path.join(sphinx_build_dir, builder)
    doctree_dir = os.path.join(sphinx_build_dir, "doctrees")
    # See if we have been told to only process a particular file
    src_file = os.environ.get("DOCS_SRC_FILE", None)

    argv = [sys.executable, "-b", builder, "-d", doctree_dir, src_dir, output_dir]
    if src_file is not None:
        argv.append(src_file)
    # run
    sys.exit(sphinx.main(argv))

##################################################################################

if __name__ == "__main__":
    main()