Parser for python source files¶
Remove any common leading whitespace from every line in text.
This can be used to make triple-quoted strings line up with the left edge of the display, while still presenting them in the source code in indented form.
Note that tabs and spaces are both treated as whitespace, but they are not equal: the lines ” hello” and “thello” are considered to have no common leading whitespace. (This behaviour is new in Python 2.5; older versions of this module incorrectly expanded tabs before searching for common leading whitespace.)
Pull out the file-specific config specified in the docstring.
Separate filename content between docstring and the rest
Strongly inspired from ast.get_docstring.
- docstring (str) – docstring of filename
- rest (str) – filename content without the docstring
Return list with source file separated into code and text blocks.
- file_conf (dict) – File-specific settings given in comments as: # sphinx_gallery_<name> = <value>
- blocks (list of (label, content)) – List where each element is a tuple with the label (‘text’ or ‘code’), and content string of block.