mik-laj 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_r266183948
########## 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: Diff changes: https://pastebin.com/W4eHex7C Line 1-5: I changed the name of the class. No comemnts Line 6-15: I updated description of class. No comments Line 16-17: I remove caption. Now, we use a filename as a caption allways. Line 18-19 At the time of writing PR, there were no validation types in the project. Line 20-25: There are two changes here. a) I dropped support for translating the message. We do not support translations in the project. b) I pass a arguments to logger. Reason available: https://github.com/apache/airflow/pull/4804 Line 26-38. a) I dropped caption support. It was conflicting with the new header. b) I added a new header. This uses the file name as the header content. > Unless I'm missing something (I've only had a quick look) I think we should be able to do this as something like: I did not find the official API to make a distinction. This is just one class and I decided it would be better to copy it. I've done research on how other people implement extensions for this directive and other people also copy the full class code https://github.com/FabriceSalvaire/sphinx-getthecode/blob/master/sphinxcontrib/getthecode.py#L27-L32 ---------------------------------------------------------------- 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
