Browse Source

SphinxPlugin: run sphinx-build directly against content dir

main
Ryan Kelly 13 years ago
parent
commit
43e36de336
3 changed files with 5 additions and 19 deletions
  1. +5
    -18
      hyde/ext/plugins/sphinx.py
  2. +0
    -1
      hyde/tests/ext/optipng/hyde-lt-b.png
  3. BIN
      hyde/tests/ext/optipng/hyde-lt-b.png

+ 5
- 18
hyde/ext/plugins/sphinx.py View File

@@ -87,30 +87,17 @@ class SphinxPlugin(Plugin):
def _run_sphinx(self):
"""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())
# 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)
sphinx_args = ["sphinx-build"]
sphinx_args.extend([
"-b", "json",
"-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:
raise RuntimeError("sphinx build failed")
@@ -118,6 +105,6 @@ class SphinxPlugin(Plugin):
def _get_sphinx_output(self,resource):
relpath = File(resource.relative_path)
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)


+ 0
- 1
hyde/tests/ext/optipng/hyde-lt-b.png View File

@@ -1 +0,0 @@
../../../../resources/hyde-lt-b.png

BIN
hyde/tests/ext/optipng/hyde-lt-b.png View File

Before After
Width: 538  |  Height: 132  |  Size: 7.9 KiB

Loading…
Cancel
Save