You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2015/12/30 10:14:42 UTC

[02/11] libcloud git commit: Try a hack to avoid warnings from docstrings.

Try a hack to avoid warnings from docstrings.

For now, we just want to treat, non-docstring related warnings as errors.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/68b6c2d5
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/68b6c2d5
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/68b6c2d5

Branch: refs/heads/trunk
Commit: 68b6c2d5d8553ead2ad278d0ce16d794c4a3776c
Parents: bed9fb6
Author: Tomaz Muraus <to...@tomaz.me>
Authored: Wed Dec 30 15:49:06 2015 +0800
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Wed Dec 30 16:13:58 2015 +0800

----------------------------------------------------------------------
 docs/conf.py | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/68b6c2d5/docs/conf.py
----------------------------------------------------------------------
diff --git a/docs/conf.py b/docs/conf.py
index 6bd17cb..155a30a 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -11,9 +11,15 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-import sys, os
+import os
+import sys
 import subprocess
 
+from sphinx.environment import BuildEnvironment
+
+from sphinx.ext.autodoc import AutoDirective
+from sphinx.ext.autodoc import AutodocReporter
+
 # Detect if we are running on read the docs
 on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
 
@@ -263,3 +269,29 @@ texinfo_documents = [
 intersphinx_mapping = {'http://docs.python.org/': None}
 
 autoclass_content = 'both'
+
+
+# Note: For now we ignore sphinx-autodoc warnings since there are too many
+# and we want at least documentation (not docstring) related warnings to be
+# reported, treated as errors and fixed.
+def noop(*args, **kwargs):
+    pass
+
+def mock_warning(self, *args, **kwargs):
+    # We re-write warning as info (level 1)
+    return self.system_message(1, *args, **kwargs)
+
+original_warn_node = BuildEnvironment.warn_node
+
+def ignore_more_than_one_target_found_errors(self, msg, node):
+    if "more than one target found" in msg:
+        return None
+
+    return original_warn_node(self, msg, node)
+
+
+# Monkey patch the original methods
+AutoDirective.warn = noop
+AutodocReporter.warning = mock_warning
+
+BuildEnvironment.warn_node = ignore_more_than_one_target_found_errors