champollion.parser.helper

champollion.parser.helper.filter_comments(content, filter_multiline_comment=True, keep_content_size=False)[source]

Return content without the comments.

If filter_multiline_comment is set to False, only the one line comment will be filtered out.

If keep_content_size is set to True, the size of the content is preserved.

Note

The filtered content keep the same number of lines as the original content.

champollion.parser.helper.collapse_all(content, filter_comment=False)[source]

Return tuple of content with the top level elements only and dictionary containing the collapsed content associated with the line number.

If filter_comment is set to True, all comment are removed from the content before collapsing the elements. The collapsed content dictionary preserve the comments.

Note

The content with collapsed elements keep the same number of lines as the original content.

champollion.parser.helper.get_docstring(line_number, lines)[source]

Return docstrings for an element at a specific line_number.

Loop into the file lines in reverse, starting from the element’s line_number in order to parse the docstring if available.

The docstring must be in the form of:

/**
 * Class doc.
 *
 * Detailed description.
 */
class AwesomeClass {
   ...
}

Which will return the following result:

"Class doc.\n\nDetailed description."

The docstring can also fit on one line, in the form of:

/** Class doc. */
class AwesomeClass {
   ...
}