sphinx_gallery.py_source_parser¶
Parser for python source files¶
Functions¶
-
sphinx_gallery.py_source_parser.extract_file_config(content)[source]¶ Pull out the file-specific config specified in the docstring.
Examples using sphinx_gallery.py_source_parser.extract_file_config¶
Examples using sphinx_gallery.py_source_parser.parse_source_file¶
-
sphinx_gallery.py_source_parser.remove_config_comments(code_block)[source]¶ Return the content of code_block with in-file config comments removed.
Comment lines of the pattern ‘# sphinx_gallery_[option] = [val]’ are removed, but surrounding empty lines are preserved.
- Parameters
code_block (str) – A code segment.
Examples using sphinx_gallery.py_source_parser.remove_config_comments¶
-
sphinx_gallery.py_source_parser.split_code_and_text_blocks(source_file, return_node=False)[source]¶ Return list with source file separated into code and text blocks.
- Parameters
- Returns
file_conf (dict) – File-specific settings given in source file comments as:
# sphinx_gallery_<name> = <value>blocks (list) – (label, content, line_number) List where each element is a tuple with the label (‘text’ or ‘code’), the corresponding content string of block and the leading line number
node (ast Node) – The parsed node.