Newer
Older
"""We need to run Sphinx inside MantidPlot to document the internal
module. This script calls the sphinx entry point with the necessary
#-----------------------------------------------------------------------------------------------
def pathjoin(left, *args):
"""
Similar to os.path.join but just uses "/" as it's populated with CMake-style paths that are
always "/" separated, even on Windows.
"""
return left + "/" + "/".join(args)
Gigg, Martyn Anthony
committed
#-----------------------------------------------------------------------------------------------
# Update path to find mantid
package_dir = "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@"
runtime_config = os.environ.get("RUNTIME_CONFIG", "") # for visual studio and xcode
if runtime_config != "":
Gigg, Martyn Anthony
committed
package_dir = pathjoin(package_dir, runtime_config)
sys.path.insert(0, package_dir)
# Update environment with screenshots path
screenshots_dir = "@SCREENSHOTS_DIR@"
if screenshots_dir != "":
os.environ["SCREENSHOTS_DIR"] = screenshots_dir
Gigg, Martyn Anthony
committed
# All paths are cmake style so are "/" separated, even on Windows
src_dir = "@SPHINX_SRC_DIR@"
Gigg, Martyn Anthony
committed
conf_dir = "@SPHINX_CONF_DIR@"
sphinx_build_dir = "@SPHINX_BUILD_DIR@"
Gigg, Martyn Anthony
committed
output_dir = pathjoin(sphinx_build_dir, builder)
doctree_dir = pathjoin(sphinx_build_dir, "doctrees")
Gigg, Martyn Anthony
committed
# Arguments for main
argv = [sys.executable,
"-b", builder,
"-d", doctree_dir,
"-c", conf_dir,
src_dir, output_dir]
# See if we have been told to only process a particular file
src_file = os.environ.get("SPHINX_SRC_FILE", None)
if src_file is not None:
argv.append(src_file)
Gigg, Martyn Anthony
committed
# Run
import sphinx
sys.exit(sphinx.main(argv))
##################################################################################
if __name__ == "__main__":
main()