Commits

Anonymous committed 35c2fa9

New config value "keep_warnings", default is to discard the from the saved doctrees.

  • Participants
  • Parent commits f1c885f

Comments (0)

Files changed (5)

   have Sphinx documentation, which will build the docs and place them
   in the standard distutils build directory.
 
+* "System Message" warnings are now automatically removed from the
+  built documentation, and only written to stderr.  If you want the
+  old behavior, set the new config value ``keep_warnings`` to True.
+
 * ``SerializingHTMLBuilder`` was added as new abstract builder that
   can be subclassed to serialize build HTML in a specific format.
   The ``PickleHTMLBuilder`` is a concrete subclass of it that uses

File doc/config.rst

    The document name of the "master" document, that is, the document that
    contains the root :dir:`toctree` directive.  Default is ``'contents'``.
 
+.. confval:: unused_docs
+
+   A list of document names that are present, but not currently included in the
+   toctree.  Use this setting to suppress the warning that is normally emitted
+   in that case.
+
+.. confval:: exclude_dirs
+
+   A list of directory names, relative to the source directory, that are to be
+   excluded from the search for source files.
+
+   .. versionadded:: 0.3
+
+.. confval:: exclude_trees
+
+   A list of directory names, relative to the source directory, that are to be
+   recursively exlucded from the search for source files, that is, their
+   subdirectories won't be searched too.
+
+   .. versionadded:: 0.4
+
+.. confval:: locale_dirs
+
+   .. versionadded:: 0.5
+
+   Directories in which to search for additional Sphinx message catalogs (see
+   :confval:`language`), relative to the source directory.  The directories on
+   this path are searched by the standard :mod:`gettext` module for a domain of
+   ``sphinx``; so if you add the directory :file:`./locale` to this settting,
+   the message catalogs must be in
+   :file:`./locale/{language}/LC_MESSAGES/sphinx.mo`.
+
+   The default is ``[]``.
+
+.. confval:: templates_path
+
+   A list of paths that contain extra templates (or templates that overwrite
+   builtin templates).  Relative paths are taken as relative to the
+   configuration directory.
+
+.. confval:: template_bridge
+
+   A string with the fully-qualified name of a callable (or simply a class) that
+   returns an instance of :class:`~sphinx.application.TemplateBridge`.  This
+   instance is then used to render HTML documents, and possibly the output of
+   other builders (currently the changes builder).
+
+.. confval:: default_role
+
+   The name of a reST role (builtin or Sphinx extension) to use as the default
+   role, that is, for text marked up ```like this```.  This can be set to
+   ``'obj'`` to make ```filter``` a cross-reference to the function "filter".
+   The default is ``None``, which doesn't reassign the default role.
+
+   The default role can always be set within individual documents using the
+   standard reST :dir:`default-role` directive.
+
+   .. versionadded:: 0.4
+
+.. confval:: keep_warnings
+
+   If true, keep warnings as "system message" paragraphs in the built documents.
+   Regardless of this setting, warnings are always written to the standard error
+   stream when ``sphinx-build`` is run.
+
+   The default is ``False``, the pre-0.5 behavior was to always keep them.
+
+   .. versionadded:: 0.5
+
+
+Project information
+-------------------
+   
 .. confval:: project
 
    The documented project's name.
    * ``en`` -- English
    * ``fr`` -- French
 
-.. confval:: locale_dirs
-
-   .. versionadded:: 0.5
-
-   Additional directories to search for Sphinx message catalogs, relative to the
-   source directory.  The directories on this path are searched by the standard
-   :mod:`gettext` module for a domain of ``sphinx``; so if you add the directory
-   :file:`./locale` to this settting, the message catalogs must be in
-   :file:`./locale/{language}/LC_MESSAGES/sphinx.mo`.
-
-   The default is ``[]``.
-   
 .. confval:: today
              today_fmt
 
    %Y'`` (or, if translation is enabled with :confval:`language`, am equivalent
    %format for the selected locale).
 
-.. confval:: unused_docs
-
-   A list of document names that are present, but not currently included in the
-   toctree.  Use this setting to suppress the warning that is normally emitted
-   in that case.
-
-.. confval:: exclude_dirs
-
-   A list of directory names, relative to the source directory, that are to be
-   excluded from the search for source files.
-
-   .. versionadded:: 0.3
-
-.. confval:: exclude_trees
-
-   A list of directory names, relative to the source directory, that are to be
-   recursively exlucded from the search for source files, that is, their
-   subdirectories won't be searched too.
-
-   .. versionadded:: 0.4
-
 .. confval:: pygments_style
 
    The style name to use for Pygments highlighting of source code.  Default is
       If the value is a fully-qualified name of a custom Pygments style class,
       this is then used as custom style.
 
-.. confval:: templates_path
-
-   A list of paths that contain extra templates (or templates that overwrite
-   builtin templates).  Relative paths are taken as relative to the
-   configuration directory.
-
-.. confval:: template_bridge
-
-   A string with the fully-qualified name of a callable (or simply a class) that
-   returns an instance of :class:`~sphinx.application.TemplateBridge`.  This
-   instance is then used to render HTML documents, and possibly the output of
-   other builders (currently the changes builder).
-
-.. confval:: default_role
-
-   The name of a reST role (builtin or Sphinx extension) to use as the default
-   role, that is, for text marked up ```like this```.  This can be set to
-   ``'obj'`` to make ```filter``` a cross-reference to the function "filter".
-   The default is ``None``, which doesn't reassign the default role.
-
-   The default role can always be set within individual documents using the
-   standard reST :dir:`default-role` directive.
-
-   .. versionadded:: 0.4
-
 .. confval:: add_function_parentheses
 
    A boolean that decides whether parentheses are appended to function and

File sphinx/config.py

         pygments_style = ('sphinx', False),
         templates_path = ([], False),
         template_bridge = (None, False),
+        keep_warnings = (False, True),
 
         # HTML options
         html_title = (lambda self: '%s v%s documentation' %

File sphinx/environment.py

     """
     Add our own transforms.
     """
-    transforms = [DefaultSubstitutions, MoveModuleTargets,
-                  FilterMessages, HandleCodeBlocks]
+    transforms = [DefaultSubstitutions, MoveModuleTargets, HandleCodeBlocks]
     def get_transforms(self):
         tf = standalone.Reader.get_transforms(self)
         return tf + self.transforms
         doctree = publish_doctree(None, src_path, FileInput,
                                   settings_overrides=self.settings,
                                   reader=SphinxStandaloneReader())
+        self.filter_messages(doctree)
         self.process_dependencies(docname, doctree)
         self.process_images(docname, doctree)
         self.process_metadata(docname, doctree)
         else:
             return doctree
 
+    def filter_messages(self, doctree):
+        """
+        Filter system messages from a doctree.
+        """
+        filterlevel = self.config.keep_warnings and 2 or 5
+        for node in doctree.traverse(nodes.system_message):
+            if node['level'] < filterlevel:
+                node.replace_self([])
+
     def process_dependencies(self, docname, doctree):
         """
         Process docutils-generated dependency info.

File tests/root/conf.py

 # for source files.
 exclude_trees = ['_build']
 
+keep_warnings = True
+
 # If true, '()' will be appended to :func: etc. cross-reference text.
 #add_function_parentheses = True