ashb commented on a change in pull request #4894: [AIRFLOW-3996] Add view
source link to included fragments
URL: https://github.com/apache/airflow/pull/4894#discussion_r265780097
##########
File path: docs/exts/exampleinclude.py
##########
@@ -0,0 +1,189 @@
+from os import path
+
+from docutils import nodes
+from docutils.parsers.rst import directives
+from six import text_type
+from sphinx import addnodes
+from sphinx.directives.code import LiteralIncludeReader
+from sphinx.locale import _
+from sphinx.pycode import ModuleAnalyzer
+from sphinx.util import logging
+from sphinx.util import parselinenos
+from sphinx.util.docutils import SphinxDirective
+from sphinx.util.nodes import set_source_info
+
+logger = logging.getLogger(__name__)
+
+
+class example_header(nodes.reference, nodes.FixedTextElement):
+ pass
+
+
+class ExampleInclude(SphinxDirective):
Review comment:
Unless I'm missing something (I've only had a _quick_ look) I think we
should be able to do this as something like:
```python
def run(self):
_, filename = self.env.relfn2path(self.arguments[0])
retnode, = super().run()
container_node = nodes.container("", literal_block=True,
classes=["example-block-wrapper"])
container_node += example_header(filename=filename)
container_node += retnode
retnode = container_node
return [retnode]
```
?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services