Repository: melexis/warnings-plugin

Issue:
Some RST warnings are not recognized
Example of warning not recognized:

```
/path/to/file.rst:None: WARNING: Traceability: cannot link to XXX, item is not defined
```

Rumours say it is because of a missing line number, and more rumours say that this regex would work

```
^(.+?:None): (DEBUG|INFO|WARNING|ERROR|SEVERE): (.+)\n?$
```

Warning is from mlx.traceability plugin, which could print a line number iso the None (see issue https://github.com/melexis/sphinx-traceability-extension/issues/2).


Discussion:

Patch:
diff --git a/setup.py b/setup.py
index 5672ae8..8f049c5 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ from os.path import basename, dirname, join, splitext
 from setuptools import find_packages, setup
 
 PROJECT_URL = 'https://github.com/melexis/warnings-plugin'
-VERSION = '0.0.4'
+VERSION = '0.0.5'
 
 
 def read(*names, **kwargs):
diff --git a/src/mlx/warnings.py b/src/mlx/warnings.py
index 4c45974..3112a5f 100644
--- a/src/mlx/warnings.py
+++ b/src/mlx/warnings.py
@@ -6,7 +6,7 @@ import math
 DOXYGEN_WARNING_REGEX = r"(?:(?:((?:[/.]|[A-Za-z]:).+?):(-?\d+):\s*([Ww]arning|[Ee]rror)|<.+>:-?\d+(?::\s*([Ww]arning|[Ee]rror))?): (.+(?:\n(?!\s*(?:[Nn]otice|[Ww]arning|[Ee]rror): )[^/<\n][^:\n][^/\n].+)*)|\s*([Nn]otice|[Ww]arning|[Ee]rror): (.+))$"
 doxy_pattern = re.compile(DOXYGEN_WARNING_REGEX)
 
-SPHINX_WARNING_REGEX = r"^(.+?:\d+): (DEBUG|INFO|WARNING|ERROR|SEVERE): (.+)\n?$"
+SPHINX_WARNING_REGEX = r"^(.+?:(?:\d+|None)): (DEBUG|INFO|WARNING|ERROR|SEVERE): (.+)\n?$"
 sphinx_pattern = re.compile(SPHINX_WARNING_REGEX)
 
 


Test patch:
diff --git a/tests/test_sphinx.py b/tests/test_sphinx.py
index a9977fe..354a255 100644
--- a/tests/test_sphinx.py
+++ b/tests/test_sphinx.py
@@ -15,6 +15,11 @@ class TestSphinxWarnings(TestCase):
         self.warnings.check_sphinx_warnings("/home/bljah/test/index.rst:5: WARNING: toctree contains reference to nonexisting document u'installation'")
         self.assertEqual(self.warnings.return_sphinx_warnings(), 1)
 
+    def test_single_warning_no_line_number(self):
+        self.warnings.check_sphinx_warnings("/home/bljah/test/index.rst:5: WARNING: toctree contains reference to nonexisting document u'installation'")
+        self.warnings.check_sphinx_warnings("/home/bljah/test/index.rst:None: WARNING: toctree contains reference to nonexisting document u'installation'")
+        self.assertEqual(self.warnings.return_sphinx_warnings(), 2)
+
     def test_single_warning_mixed(self):
         self.warnings.check_sphinx_warnings('This1 should not be treated as warning')
         self.warnings.check_sphinx_warnings("/home/bljah/test/index.rst:5: WARNING: toctree contains reference to nonexisting document u'installation'")