Adds a referenceable type to logging warnings
This allows users to use the sphinx config `suppress_warnings = ['autoapi']` to ignore warnings emitted from autoapi.
This commit is contained in:
parent
66f3734afa
commit
bec1f6c1b0
5 changed files with 20 additions and 18 deletions
|
|
@ -104,9 +104,11 @@ class DotNetSphinxMapper(SphinxMapperBase):
|
|||
)
|
||||
_, error_output = proc.communicate()
|
||||
if error_output:
|
||||
LOGGER.warning(error_output)
|
||||
LOGGER.warning(error_output, type="autoapi")
|
||||
except (OSError, subprocess.CalledProcessError):
|
||||
LOGGER.warning("Error generating metadata", exc_info=True)
|
||||
LOGGER.warning(
|
||||
"Error generating metadata", exc_info=True, type="autoapi"
|
||||
)
|
||||
if raise_error:
|
||||
raise ExtensionError(
|
||||
"Failure in docfx while generating AutoAPI output."
|
||||
|
|
@ -131,9 +133,9 @@ class DotNetSphinxMapper(SphinxMapperBase):
|
|||
parsed_data = yaml.safe_load(handle)
|
||||
return parsed_data
|
||||
except IOError:
|
||||
LOGGER.warning("Error reading file: {0}".format(path))
|
||||
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi")
|
||||
except TypeError:
|
||||
LOGGER.warning("Error reading file: {0}".format(path))
|
||||
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi")
|
||||
return None
|
||||
|
||||
# Subclassed to iterate over items
|
||||
|
|
@ -172,7 +174,7 @@ class DotNetSphinxMapper(SphinxMapperBase):
|
|||
try:
|
||||
cls = obj_map[data["type"].lower()]
|
||||
except KeyError:
|
||||
LOGGER.warning("Unknown type: %s" % data)
|
||||
LOGGER.warning("Unknown type: %s" % data, type="autoapi")
|
||||
else:
|
||||
obj = cls(
|
||||
data, jinja_env=self.jinja_env, app=self.app, options=options, **kwargs
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ class GoSphinxMapper(SphinxMapperBase):
|
|||
parsed_data = json.loads(subprocess.check_output(parser_command))
|
||||
return parsed_data
|
||||
except IOError:
|
||||
LOGGER.warning("Error reading file: {0}".format(path))
|
||||
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi")
|
||||
except TypeError:
|
||||
LOGGER.warning("Error reading file: {0}".format(path))
|
||||
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi")
|
||||
return None
|
||||
|
||||
def create_class(self, data, options=None, **kwargs):
|
||||
|
|
@ -83,7 +83,7 @@ class GoSphinxMapper(SphinxMapperBase):
|
|||
else:
|
||||
cls = obj_map[data["type"]]
|
||||
except KeyError:
|
||||
LOGGER.warning("Unknown Type: %s" % data)
|
||||
LOGGER.warning("Unknown Type: %s" % data, type="autoapi")
|
||||
else:
|
||||
if cls.inverted_names and "names" in data:
|
||||
# Handle types that have reversed names parameter
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ class JavaScriptSphinxMapper(SphinxMapperBase):
|
|||
parsed_data = json.loads(subprocess.check_output([subcmd, "-X", path]))
|
||||
return parsed_data
|
||||
except IOError:
|
||||
LOGGER.warning("Error reading file: {0}".format(path))
|
||||
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi")
|
||||
except TypeError:
|
||||
LOGGER.warning("Error reading file: {0}".format(path))
|
||||
LOGGER.warning("Error reading file: {0}".format(path), type="autoapi")
|
||||
return None
|
||||
|
||||
# Subclassed to iterate over items
|
||||
|
|
@ -71,7 +71,7 @@ class JavaScriptSphinxMapper(SphinxMapperBase):
|
|||
try:
|
||||
cls = obj_map[data["kind"]]
|
||||
except (KeyError, TypeError):
|
||||
LOGGER.warning("Unknown Type: %s" % data)
|
||||
LOGGER.warning("Unknown Type: %s" % data, type="autoapi")
|
||||
else:
|
||||
# Recurse for children
|
||||
obj = cls(data, jinja_env=self.jinja_env, app=self.app)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ def _expand_wildcard_placeholder(original_module, originals_map, placeholder):
|
|||
msg = "Invalid __all__ entry {0} in {1}".format(
|
||||
name, original_module["name"]
|
||||
)
|
||||
LOGGER.warning(msg)
|
||||
LOGGER.warning(msg, type="autoapi")
|
||||
continue
|
||||
|
||||
originals.append(originals_map[name])
|
||||
|
|
@ -107,7 +107,7 @@ def _resolve_module_placeholders(modules, module_name, visit_path, resolved):
|
|||
msg = "Cannot resolve cyclic import: {0}, {1}".format(
|
||||
", ".join(visit_path), imported_from
|
||||
)
|
||||
LOGGER.warning(msg)
|
||||
LOGGER.warning(msg, type="autoapi")
|
||||
module["children"].remove(child)
|
||||
children.pop(child["name"])
|
||||
continue
|
||||
|
|
@ -116,7 +116,7 @@ def _resolve_module_placeholders(modules, module_name, visit_path, resolved):
|
|||
msg = "Cannot resolve import of unknown module {0} in {1}".format(
|
||||
imported_from, module_name
|
||||
)
|
||||
LOGGER.warning(msg)
|
||||
LOGGER.warning(msg, type="autoapi")
|
||||
module["children"].remove(child)
|
||||
children.pop(child["name"])
|
||||
continue
|
||||
|
|
@ -144,7 +144,7 @@ def _resolve_module_placeholders(modules, module_name, visit_path, resolved):
|
|||
msg = "Cannot resolve import of {0} in {1}".format(
|
||||
child["original_path"], module_name
|
||||
)
|
||||
LOGGER.warning(msg)
|
||||
LOGGER.warning(msg, type="autoapi")
|
||||
module["children"].remove(child)
|
||||
children.pop(child["name"])
|
||||
continue
|
||||
|
|
@ -318,8 +318,8 @@ class PythonSphinxMapper(SphinxMapperBase):
|
|||
parsed_data = Parser().parse_file(path)
|
||||
return parsed_data
|
||||
except (IOError, TypeError, ImportError):
|
||||
LOGGER.warning("Unable to read file: {0}".format(path))
|
||||
LOGGER.debug("Reason:", exc_info=True)
|
||||
LOGGER.warning("Unable to read file: {0}".format(path), type="autoapi")
|
||||
return None
|
||||
|
||||
def _resolve_placeholders(self):
|
||||
|
|
@ -359,7 +359,7 @@ class PythonSphinxMapper(SphinxMapperBase):
|
|||
try:
|
||||
cls = self._OBJ_MAP[data["type"]]
|
||||
except KeyError:
|
||||
LOGGER.warning("Unknown type: %s" % data["type"])
|
||||
LOGGER.warning("Unknown type: %s" % data["type"], type="autoapi")
|
||||
else:
|
||||
obj = cls(
|
||||
data,
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ def _get_toc_reference(node, toc, docname):
|
|||
ref_id = node.children[0].attributes["ids"][0]
|
||||
toc_reference = _find_toc_node(toc, ref_id, addnodes.desc)
|
||||
except (KeyError, IndexError):
|
||||
LOGGER.warning("Invalid desc node", exc_info=True)
|
||||
LOGGER.warning("Invalid desc node", exc_info=True, type="autoapi")
|
||||
toc_reference = None
|
||||
|
||||
return toc_reference
|
||||
|
|
|
|||
Loading…
Reference in a new issue