Repository: sphinx-doc/sphinx

Issue:
autosummary "first-sentence" detection fails for some abbreviations
### Describe the bug

If a docstring's first sentence contains an abbreviation such as `e.g.`, autosummary incorrectly cuts the summary immediately after the abbreviation.

Also fails if the first sentence includes: `(i.e. word, word, etc)`

### How to Reproduce

```bash
$ sphinx-quickstart --sep -m -p foo -a author -r0 -len --extensions sphinx.ext.autosummary
```
edit `index.html` to contain:
```
.. autosummary::
   foo.foo
```
edit foo.py to contain
```
def foo():
    """
    Does foo (e.g. foo the thing)
    """
```
this results in truncated output: `Does foo (e.g.`

### Environment Information

```text
sphinx latest
```


### Sphinx extensions

```python
sphinx.ext.autosummary
```


### Additional context

Need to add `e.g.` to https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/autosummary/__init__.py#L102

WELL_KNOWN_ABBREVIATIONS should also support `(e.g.` and `(i.e.`

Relates to #7865

Discussion:
AA-Turner: @grayjk -- please could you add an entry to CHANGES?

A

Patch:
diff --git a/CHANGES b/CHANGES
index 645a6cd4c..e05488388 100644
--- a/CHANGES
+++ b/CHANGES
@@ -44,6 +44,7 @@ Bugs fixed
   Patch by Ralf Grubenmann.
 * #11529: Line Block in LaTeX builder outputs spurious empty token.
   Patch by Adrian Vollmer.
+* #11196: autosummary: Summary line extraction failed with "e.g."
 
 Testing
 -------
diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py
index ddee2fa5a..ff948d83d 100644
--- a/sphinx/ext/autosummary/__init__.py
+++ b/sphinx/ext/autosummary/__init__.py
@@ -100,7 +100,7 @@
 periods_re = re.compile(r'\.(?:\s+)')
 literal_re = re.compile(r'::\s*$')
 
-WELL_KNOWN_ABBREVIATIONS = ('et al.', ' i.e.',)
+WELL_KNOWN_ABBREVIATIONS = ('et al.', 'e.g.', 'i.e.')
 
 
 # -- autosummary_toc node ------------------------------------------------------


Test patch:
diff --git a/tests/test_ext_autosummary.py b/tests/test_ext_autosummary.py
index 0f917df1e..93cf195af 100644
--- a/tests/test_ext_autosummary.py
+++ b/tests/test_ext_autosummary.py
@@ -102,6 +102,15 @@ def test_extract_summary(capsys):
     doc = ['Blabla, i.e. bla.']
     assert extract_summary(doc, document) == ' '.join(doc)
 
+    doc = ['Blabla, (i.e. bla).']
+    assert extract_summary(doc, document) == ' '.join(doc)
+
+    doc = ['Blabla, e.g. bla.']
+    assert extract_summary(doc, document) == ' '.join(doc)
+
+    doc = ['Blabla, (e.g. bla).']
+    assert extract_summary(doc, document) == ' '.join(doc)
+
     doc = ['Blabla, et al. bla.']
     assert extract_summary(doc, document) == ' '.join(doc)