2019-11-13 03:46:16 +00:00
|
|
|
import os.path
|
2021-01-26 02:49:01 +00:00
|
|
|
|
2019-11-28 21:56:53 +00:00
|
|
|
from docutils.parsers.rst import directives
|
2019-11-13 03:46:16 +00:00
|
|
|
from docutils.parsers.rst.directives.misc import Include as BaseInclude
|
|
|
|
from sphinx.util.docutils import SphinxDirective
|
|
|
|
|
2019-11-28 21:56:53 +00:00
|
|
|
|
2019-11-13 03:46:16 +00:00
|
|
|
class IncludeBuildFile(BaseInclude, SphinxDirective):
|
|
|
|
"""
|
|
|
|
Like the standard "Include" directive, but relative to the app
|
|
|
|
build directory
|
|
|
|
"""
|
|
|
|
def run(self):
|
|
|
|
abspath = os.path.join(self.env.config.build_dir, self.arguments[0])
|
|
|
|
self.arguments[0] = abspath
|
|
|
|
self.env.note_included(abspath)
|
|
|
|
return super(IncludeBuildFile, self).run()
|
|
|
|
|
2019-11-28 21:56:53 +00:00
|
|
|
|
2019-11-13 03:46:16 +00:00
|
|
|
def setup(app):
|
2019-11-28 21:56:53 +00:00
|
|
|
directives.register_directive('include-build-file', IncludeBuildFile)
|
2019-11-28 05:00:24 +00:00
|
|
|
|
2019-11-28 21:56:53 +00:00
|
|
|
return {'parallel_read_safe': True, 'parallel_write_safe': True, 'version': '0.1'}
|