# ----------------------------------------------------------------------- # This script is used to extract embedded documentation strings # from SWIG interface files. # (c) Hex-Rays # import glob import sys # --------------------------------------------------------------------------- def extract_docs(lines, out): S_SWIG_CLOSE = '%}' S_PYDOC_START = '#' S_PYDOC_END = '#' S_COMMENT = '#' S_INLINE = '%inline %{' S_PYCODE_START = '%pythoncode %{' in_inline = False in_pythoncode = False in_pydoc = False for line in lines: line = line.rstrip() # skip empty lines if not line: continue # Inside pythoncode tag? if in_pythoncode: if line == S_PYDOC_START: in_pydoc = True continue elif line == S_PYDOC_END: in_pydoc = False continue elif line == S_SWIG_CLOSE: in_pythoncode = False continue # Skip unneeded tags elif line[:8] == '#