def test_docstring_processing(): def process(objtype, name, obj): inst = AutoDirective._registry[objtype](directive, name) inst.object = obj inst.fullname = name return list(inst.process_doc(inst.get_doc())) class E: def __init__(self): """Init docstring""" # docstring processing by event handler assert process("class", "bar", E) == ["Init docstring", "", "42", ""] lid = app.connect("autodoc-process-docstring", cut_lines(1, 1, ["function"])) def f(): """ first line second line third line """ assert process("function", "f", f) == ["second line", ""] app.disconnect(lid) lid = app.connect("autodoc-process-docstring", between("---", ["function"])) def g(): """ first line --- second line --- third line """ assert process("function", "g", g) == ["second line", ""] app.disconnect(lid) lid = app.connect("autodoc-process-docstring", between("---", ["function"], exclude=True)) def h(): """ first line --- second line --- third line """ assert process("function", "h", h) == ["first line", "third line", ""] app.disconnect(lid)
def test_docstring_processing(): def process(objtype, name, obj): inst = AutoDirective._registry[objtype](directive, name) inst.object = obj inst.fullname = name return list(inst.process_doc(inst.get_doc())) class E: def __init__(self): """Init docstring""" # docstring processing by event handler assert process('class', 'bar', E) == ['Init docstring', '', '42', ''] lid = app.connect('autodoc-process-docstring', cut_lines(1, 1, ['function'])) def f(): """ first line second line third line """ assert process('function', 'f', f) == ['second line', ''] app.disconnect(lid) lid = app.connect('autodoc-process-docstring', between('---', ['function'])) def g(): """ first line --- second line --- third line """ assert process('function', 'g', g) == ['second line', ''] app.disconnect(lid) lid = app.connect('autodoc-process-docstring', between('---', ['function'], exclude=True)) def h(): """ first line --- second line --- third line """ assert process('function', 'h', h) == ['first line', 'third line', ''] app.disconnect(lid)
def setup(app): from sphinx.ext.autodoc import between, cut_lines global autodoc_lang if "autodoc_lang" in app.config.overrides: autodoc_lang = app.config.overrides["autodoc_lang"] app.connect("autodoc-process-docstring", between("\.\.\s\[(/|)" + autodoc_lang + "\].*", ["function"])) app.connect("autodoc-process-docstring", cut_lines(1, what=["function"]))
def setup(app): """ Registers an autodoc between listener to ignore License texts :param app: The sphinx app :return: None """ app.connect('autodoc-process-docstring', between('^.*LICENSE.*$', exclude=True)) app.connect("autodoc-skip-member", lambda a, b, name, d, skipper, f: False if name == "__init__" else skipper) return app
def test_docstring_processing_functions(): lid = app.connect('autodoc-process-docstring', cut_lines(1, 1, ['function'])) def f(): """ first line second line third line """ assert list(gen.get_doc('function', 'f', f)) == ['second line', ''] app.disconnect(lid) lid = app.connect('autodoc-process-docstring', between('---', ['function'])) def f(): """ first line --- second line --- third line """ assert list(gen.get_doc('function', 'f', f)) == ['second line', ''] app.disconnect(lid)
def setup(app): app.add_css_file('styles.css') app.connect('autodoc-process-docstring', between('^.*IGNORE.*$', exclude=True)) return app
def setup(app): # Register a sphinx.ext.autodoc.between listener to ignore everything # between lines that contain the word IGNORE app.connect('autodoc-process-docstring', between('^.*IGNORE.*$', exclude=True)) return app
def setup(app): # Register a sphinx.ext.autodoc.between listener to ignore everything # between lines that contain the word IGNORE app.connect('autodoc-process-docstring', between('(^Chemical Engineering Design Library).*|(^SOFTWARE.$).*', exclude=True)) #app.connect('autodoc-skip-member', maybe_skip_member) return app
def setup(app): from sphinx.ext.autodoc import between app.connect('autodoc-process-docstring', between('Usage:', exclude=True))
def setup(app): # Register a sphinx.ext.autodoc.between listener to ignore everything # between lines that contain the word IGNORE app.connect('autodoc-process-docstring', between('(^Chemical Engineering Design Library).*|(^SOFTWARE.$).*', exclude=True)) return app
def setup(app): ignore_separator = "^" + 88 * "-" + "$" app.connect("autodoc-process-docstring", autodoc.between(ignore_separator, exclude=True))
def setup(app): # Register a sphinx.ext.autodoc.between listener to ignore everything # between lines that contain the word -#-#-#- app.connect('autodoc-process-docstring', between('^.*#-SPHINX-IGNORE-#.*$', exclude=True)) return app
def setup(app): from sphinx.ext.autodoc import between app.connect('autodoc-process-docstring', between(r'=====API DOCS=====', keepempty=True, what=["method"]))
def setup(app): from sphinx.highlighting import lexers from pygments.lexer import RegexLexer, bygroups from pygments.token import Comment, Text, Number app.connect('autodoc-process-docstring', between('^.*___int_doc.*$', exclude=True))
def process_docstring(app, what, name, obj, options, lines): from docs.feature_annotation_parser import parse_feature_annotation docstring = "\n".join(lines) annotation_list = parse_feature_annotation(docstring) process_between = between(marker="--ge-feature-maturity-info--", exclude=True) process_between(app, what, name, obj, options, lines) if not annotation_list: return feature_annotation_admonition = """ .. admonition:: `Feature Maturity <https://docs.greatexpectations.io/en/latest/features>`_ """ feature_annotation_template = """ | |icon-{icon_hash}| **{title}** - `How-to Guide <{how_to_guide_url}>`_ | {description} | **Maturity**: {maturity} | **Details**: | **API Stability**: {maturity_details[api_stability]} | **Implementation Completeness**: {maturity_details[implementation_completeness]} | **Unit Test Coverage**: {maturity_details[unit_test_coverage]} | **Integration Infrastructure/Test Coverage**: {maturity_details[integration_infrastructure_test_coverage]} | **Documentation Completeness**: {maturity_details[documentation_completeness]} | **Bug Risk**: {maturity_details[bug_risk]}\ """ expectation_completeness_template = """ | **Expectation Completeness**: {maturity_details[expectation_completeness]}\ """ icon_template = """ .. |icon-{icon_hash}| image:: {icon} :height: 15px """ for annotation in annotation_list: icon_hash = uuid.uuid1().hex annotation["icon_hash"] = icon_hash description = (annotation.get("description") or annotation.get("short_description") or f"*TODO: {annotation.get('title')} Description*") how_to_guide_url = ( annotation.get("how_to_guide_url") or "https://docs.greatexpectations.io/en/latest/how_to_guides.html") annotation["how_to_guide_url"] = how_to_guide_url annotation["description"] = description if annotation["maturity_details"].get("expectation_completeness"): feature_annotation_admonition += ( feature_annotation_template + expectation_completeness_template + icon_template).format(**annotation) else: feature_annotation_admonition += (feature_annotation_template + icon_template).format( **annotation) lines += feature_annotation_admonition.splitlines()
def setup(app): app.add_css_file("custom.css") ignore_separator = "^" + 88 * "-" + "$" app.connect("autodoc-process-docstring", autodoc.between(ignore_separator, exclude=True))
def setup(app): #app.add_javascript('copybutton.js') # Register a sphinx.ext.autodoc.between listener to ignore everything # between lines that contain the word IGNORE app.connect('autodoc-process-docstring', between('(^Chemical Engineering Design Library).*|(^SOFTWARE.$).*', exclude=True)) return app