# Docutils uses a deprecated U mode for opening files, so instead of
# monkey-patching docutils.io.FileInput to not do that (like Pelican does),
# I just read the thing myself.
- # TODO for external docs it *somehow* needs to supply the filename and line
- # range to it for better error reporting, this is too awful
+ # TODO for external docs it *somehow* needs to supply the *proper* filename
+ # and line range to it for better error reporting and relative includes,
+ # this is too awful
+ if not source_path:
+ source_path=os.path.join(state.config['INPUT'], "file.rst")
pub.set_source(source=source, source_path=source_path)
pub.publish()
return pub
def render_rst(state: State, source):
- return publish_rst(state, source, source_path=None).writer.parts.get('body').rstrip()
+ return publish_rst(state, source).writer.parts.get('body').rstrip()
class _SaneInlineHtmlTranslator(m.htmlsanity.SaneHtmlTranslator):
# Unconditionally force compact paragraphs. This means the inline HTML
docutils.utils.extract_options = _docutils_extract_options
docutils.utils.assemble_option_dict = _docutils_assemble_option_dict
- publish_rst(state, f.read())
+ publish_rst(state, f.read(), source_path=filename)
docutils.utils.extract_options = prev_extract_options
docutils.utils.assemble_option_dict = prev_assemble_option_dict
</ul>
</div>
<p>This is detailed module docs. I kinda <em>hate</em> how it needs to be indented,
-tho.</p>
+tho. Below is an included file to test file path is supplied somewhat
+correctly (relative to the input dir):</p>
+<pre># This module has an external summary
+</pre>
<section id="namespaces">
<h2><a href="#namespaces">Modules</a></h2>
<dl class="m-doc">
:data ANOTHER_DOCUMENTED_INSIDE_MODULE: In-module summary for another data
This is detailed module docs. I kinda *hate* how it needs to be indented,
- tho.
+ tho. Below is an included file to test file path is supplied somewhat
+ correctly (relative to the input dir):
+
+ .. include:: content/submodule.py
+ :literal:
.. py:module:: content.docstring_summary