|
@@ -87,30 +87,17 @@ class SphinxPlugin(Plugin): |
|
|
def _run_sphinx(self): |
|
|
def _run_sphinx(self): |
|
|
"""Run sphinx to generate the necessary output files. |
|
|
"""Run sphinx to generate the necessary output files. |
|
|
|
|
|
|
|
|
This method creates a temporary directory, copies all sphinx-related |
|
|
|
|
|
files into it, and then runs the sphinx build process to produce |
|
|
|
|
|
the documentation fragments. |
|
|
|
|
|
|
|
|
This method creates a temporary directory for sphinx's output, then |
|
|
|
|
|
run sphinx against the Hyde input directory. |
|
|
""" |
|
|
""" |
|
|
self.sphinx_build_dir = Folder(tempfile.mkdtemp()) |
|
|
self.sphinx_build_dir = Folder(tempfile.mkdtemp()) |
|
|
# Copy all sphinx files into a temporary build directory. |
|
|
|
|
|
self.sphinx_input_dir = self.sphinx_build_dir.child_folder("input") |
|
|
|
|
|
self.sphinx_input_dir.make() |
|
|
|
|
|
for resource in self.site.content.walk_resources(): |
|
|
|
|
|
if resource.source_file.kind == "rst": |
|
|
|
|
|
relpath = resource.relative_path |
|
|
|
|
|
build_file = File(self.sphinx_input_dir.child(relpath)) |
|
|
|
|
|
build_file.parent.make() |
|
|
|
|
|
resource.source_file.copy_to(build_file) |
|
|
|
|
|
# Run sphinx to generate output in the output directory. |
|
|
|
|
|
self.sphinx_output_dir = self.sphinx_build_dir.child_folder("output") |
|
|
|
|
|
self.sphinx_output_dir.make() |
|
|
|
|
|
conf_path = self.site.sitepath.child_folder(self.settings.conf_path) |
|
|
conf_path = self.site.sitepath.child_folder(self.settings.conf_path) |
|
|
sphinx_args = ["sphinx-build"] |
|
|
sphinx_args = ["sphinx-build"] |
|
|
sphinx_args.extend([ |
|
|
sphinx_args.extend([ |
|
|
"-b", "json", |
|
|
"-b", "json", |
|
|
"-c", conf_path.path, |
|
|
"-c", conf_path.path, |
|
|
self.sphinx_input_dir.path, |
|
|
|
|
|
self.sphinx_output_dir.path |
|
|
|
|
|
|
|
|
self.site.content.path, |
|
|
|
|
|
self.sphinx_build_dir.path |
|
|
]) |
|
|
]) |
|
|
if sphinx.main(sphinx_args) != 0: |
|
|
if sphinx.main(sphinx_args) != 0: |
|
|
raise RuntimeError("sphinx build failed") |
|
|
raise RuntimeError("sphinx build failed") |
|
@@ -118,6 +105,6 @@ class SphinxPlugin(Plugin): |
|
|
def _get_sphinx_output(self,resource): |
|
|
def _get_sphinx_output(self,resource): |
|
|
relpath = File(resource.relative_path) |
|
|
relpath = File(resource.relative_path) |
|
|
relpath = relpath.parent.child(relpath.name_without_extension+".fjson") |
|
|
relpath = relpath.parent.child(relpath.name_without_extension+".fjson") |
|
|
with open(self.sphinx_output_dir.child(relpath),"rb") as f: |
|
|
|
|
|
|
|
|
with open(self.sphinx_build_dir.child(relpath),"rb") as f: |
|
|
return json.load(f) |
|
|
return json.load(f) |
|
|
|
|
|
|