def __init__(self, docstring, config=None, app=None, what='', name='', obj=None, options=None): # type: (Union[unicode, List[unicode]], SphinxConfig, Sphinx, unicode, unicode, Any, Any) -> None # NOQA self._config = config self._app = app if not self._config: from sphinxcontrib.napoleon import Config self._config = self._app and self._app.config or Config() # type: ignore if not what: if inspect.isclass(obj): what = 'class' elif inspect.ismodule(obj): what = 'module' elif isinstance(obj, collections.Callable): # type: ignore what = 'function' else: what = 'object' self._what = what self._name = name self._obj = obj self._opt = options if isinstance(docstring, string_types): docstring = docstring.splitlines() # type: ignore self._lines = docstring self._line_iter = modify_iter(docstring, modifier=lambda s: s.rstrip()) self._parsed_lines = [] # type: List[unicode] self._is_in_section = False self._section_indent = 0 if not hasattr(self, '_directive_sections'): self._directive_sections = [] # type: List[unicode] if not hasattr(self, '_sections'): self._sections = { 'args': self._parse_parameters_section, 'arguments': self._parse_parameters_section, 'attributes': self._parse_attributes_section, 'example': self._parse_examples_section, 'examples': self._parse_examples_section, 'keyword args': self._parse_keyword_arguments_section, 'keyword arguments': self._parse_keyword_arguments_section, 'methods': self._parse_methods_section, 'note': self._parse_note_section, 'notes': self._parse_notes_section, 'other parameters': self._parse_other_parameters_section, 'parameters': self._parse_parameters_section, 'return': self._parse_returns_section, 'returns': self._parse_returns_section, 'raises': self._parse_raises_section, 'references': self._parse_references_section, 'see also': self._parse_see_also_section, 'todo': self._parse_todo_section, 'warning': self._parse_warning_section, 'warnings': self._parse_warning_section, 'warns': self._parse_warns_section, 'yield': self._parse_yields_section, 'yields': self._parse_yields_section, } # type: Dict[unicode, Callable] self._parse()
def __init__(self, docstring, config=None, app=None, what="", name="", obj=None, options=None): self._config = config self._app = app if not self._config: from sphinxcontrib.napoleon import Config self._config = self._app and self._app.config or Config() if not what: if inspect.isclass(obj): what = "class" elif inspect.ismodule(obj): what = "module" elif isinstance(obj, collections.Callable): what = "function" else: what = "object" self._what = what self._name = name self._obj = obj self._opt = options if isinstance(docstring, string_types): docstring = docstring.splitlines() self._lines = docstring self._line_iter = modify_iter(docstring, modifier=lambda s: s.rstrip()) self._parsed_lines = [] self._is_in_section = False self._section_indent = 0 if not hasattr(self, "_directive_sections"): self._directive_sections = [] if not hasattr(self, "_sections"): self._sections = { "args": self._parse_parameters_section, "arguments": self._parse_parameters_section, "attributes": self._parse_attributes_section, "example": self._parse_examples_section, "examples": self._parse_examples_section, "keyword args": self._parse_keyword_arguments_section, "keyword arguments": self._parse_keyword_arguments_section, "methods": self._parse_methods_section, "note": self._parse_note_section, "notes": self._parse_notes_section, "other parameters": self._parse_other_parameters_section, "parameters": self._parse_parameters_section, "return": self._parse_returns_section, "returns": self._parse_returns_section, "raises": self._parse_raises_section, "references": self._parse_references_section, "see also": self._parse_see_also_section, "warning": self._parse_warning_section, "warnings": self._parse_warning_section, "warns": self._parse_warns_section, "yield": self._parse_yields_section, "yields": self._parse_yields_section, } self._parse()
def __init__(self, docstring: Union[str, List[str]], what: str = '', name: str = '', obj: Any = None, options: Any = None): if not what: if inspect.isclass(obj): what = 'class' elif inspect.ismodule(obj): what = 'module' elif isinstance(obj, Callable): # type: ignore what = 'function' else: what = 'object' self._what = what self._name = name self._obj = obj self._opt = options if isinstance(docstring, string_types): docstring = docstring.splitlines() self._lines = docstring self._line_iter = modify_iter(docstring, modifier=lambda s: s.rstrip()) self._parsed_lines: List[str] = [] self._is_in_section = False self._section_indent = 0 if not hasattr(self, '_sections'): self._sections: Dict[str, Callable] = { 'args': self._parse_parameters_section, 'arguments': self._parse_parameters_section, 'attributes': self._parse_attributes_section, 'example': self._parse_examples_section, 'examples': self._parse_examples_section, 'keyword args': self._parse_keyword_arguments_section, 'keyword arguments': self._parse_keyword_arguments_section, 'methods': self._parse_methods_section, 'other parameters': self._parse_other_parameters_section, 'parameters': self._parse_parameters_section, 'schema': self._parse_schemas_section, 'schemas': self._parse_schemas_section, 'map': self._parse_map_section, 'maps': self._parse_map_section, 'tag': self._parse_tags_section, 'tags': self._parse_tags_section, 'request': self._parse_requests_section, 'requests': self._parse_requests_section, 'response': self._parse_responses_section, 'responses': self._parse_responses_section, 'return': self._parse_returns_section, 'returns': self._parse_returns_section, } self._parse()