Skip to content

Commit

Permalink
Fix for incremental build
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate McMaster committed Jun 29, 2016
1 parent 9e37082 commit a39cb0a
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

if not on_rtd:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

def setup(app):
app.add_stylesheet('custom.css')
app.add_javascript('wedc.js')
app.add_stylesheet('custom.css')
app.add_javascript('wedc.js')

#html_theme = 'default'

Expand Down Expand Up @@ -307,6 +307,8 @@ def setup(app):
#texinfo_no_detailmenu = False

class SampleLiteralInclude(LiteralInclude):
filepath=""

"""
Like ``.. literalinclude``, but instead uses the samples folder to find files
"""
Expand All @@ -316,7 +318,19 @@ def read_with_encoding(self, filename, document, codec_info, encoding):
See https://github.com/sphinx-doc/sphinx/blob/master/sphinx/directives/code.py#L175
"""
samples_dir=os.path.normpath(os.path.join(os.path.dirname(__file__), '../samples'))
filename=os.path.join(samples_dir, self.arguments[0])
return super(SampleLiteralInclude, self).read_with_encoding(filename, document, codec_info, encoding)
self.filepath=os.path.join(samples_dir, self.arguments[0])
return super(SampleLiteralInclude, self).read_with_encoding(self.filepath, document, codec_info, encoding)

def run(self):
env=self.state.document.settings.env
nodes=super(SampleLiteralInclude, self).run()
env.note_dependency(self.filepath)

# base function adds incorrect filepath as dependency
rel_filename, filename = env.relfn2path(self.arguments[0])
env.dependencies.setdefault(env.docname, set()).remove(rel_filename)

return nodes


directives.register_directive('includesamplefile', SampleLiteralInclude)

2 comments on commit a39cb0a

@natemcmaster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @rowanmiller should be faster now. 🐎

@rowanmiller
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 yep works much better now 🎉

Please sign in to comment.