Repository: sphinx-doc/sphinx

Issue:
apidoc buggy on linux, not windows
Subject: When generating APIDOC, some stange "\" appears since release 1.5.4

### Problem
- Title of modules have a "\" in front of dots and underscore in title of modules

#### Procedure to reproduce the problem
```
sphinx-apidoc --separate --maxdepth 2 --doc-project "my project" --output-dir "/path"
```

#### Error logs / results
```
namespace1\.namespace2\.namespace3 module 
========================================= 
 
.. automodule:: namespace1.namespace2.namespace3
    :members: 
    :undoc-members: 
    :show-inheritance: 
```

#### Expected results
Good result should be :
```
namespace1.namespace2.namespace3 module 
======================================= 
 
.. automodule:: namespace1.namespace2.namespace3
    :members: 
    :undoc-members: 
    :show-inheritance: 
### Reproducible project / your project
```

### Environment info
- OS: Linux
- Python version: 3.5.2
- Sphinx version: 1.6.2

I notice it works well with 1.5.3 but from 1.5.4 up to 1.6.3, it doesn't
I also notice it works well on Windows...

Discussion:

Patch:
diff --git a/CHANGES b/CHANGES
index 8d95eb9f8..c00d1a594 100644
--- a/CHANGES
+++ b/CHANGES
@@ -27,6 +27,7 @@ Bugs fixed
 * #4491: autodoc: prefer _MockImporter over other importers in sys.meta_path
 * #4490: autodoc: type annotation is broken with python 3.7.0a4+
 * utils package is installed
+* #3952: apidoc: module header is too escaped
 
 Testing
 --------
diff --git a/sphinx/util/rst.py b/sphinx/util/rst.py
index 5860b0fd5..a406e0044 100644
--- a/sphinx/util/rst.py
+++ b/sphinx/util/rst.py
@@ -23,13 +23,15 @@
     # For type annotation
     from typing import Generator  # NOQA
 
-symbols_re = re.compile(r'([!-/:-@\[-`{-~])')
+symbols_re = re.compile(r'([!--/:-@\[-`{-~])')  # symbols without dot(0x2e)
 logger = logging.getLogger(__name__)
 
 
 def escape(text):
     # type: (unicode) -> unicode
-    return symbols_re.sub(r'\\\1', text)  # type: ignore
+    text = symbols_re.sub(r'\\\1', text)  # type: ignore
+    text = re.sub(r'^\.', r'\.', text)  # escape a dot at top
+    return text
 
 
 @contextmanager


Test patch:
diff --git a/tests/test_util_rst.py b/tests/test_util_rst.py
index 406ea710e..07b9174cc 100644
--- a/tests/test_util_rst.py
+++ b/tests/test_util_rst.py
@@ -14,3 +14,5 @@
 def test_escape():
     assert escape(':ref:`id`') == r'\:ref\:\`id\`'
     assert escape('footnote [#]_') == r'footnote \[\#\]\_'
+    assert escape('sphinx.application') == r'sphinx.application'
+    assert escape('.. toctree::') == r'\.. toctree\:\:'