Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nonascii object names #184

Merged
merged 6 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Changes in sphinx-automodapi

- Minimum supported Python version is now 3.8. [#177]

- Fixed issue with non-ascii characters in object names. [#184]

0.16.0 (2023-08-17)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion sphinx_automodapi/automodsumm.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def process_automodsumm_generation(app):
if app.config.automodsumm_writereprocessed:
if lines: # empty list means no automodsumm entry is in the file
outfn = os.path.join(app.srcdir, sfn) + '.automodsumm'
with open(outfn, 'w') as f:
with open(outfn, 'w', encoding='utf8') as f:
for l in lines: # noqa: E741
f.write(l)
f.write('\n')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
NonAscii
========
NonAsciiÄöüßő
=============

.. currentmodule:: sphinx_automodapi.tests.example_module.nonascii

.. autoclass:: NonAscii
.. autoclass:: NonAsciiÄöüßő
:show-inheritance:

.. rubric:: Methods Summary

.. autosummary::

~NonAscii.get_ß
~NonAscii.get_äöü
~NonAsciiÄöüßő.get_ß
~NonAsciiÄöüßő.get_äöü

.. rubric:: Methods Documentation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
.. autosummary::
:toctree: api

NonAscii
NonAsciiÄöüßő

4 changes: 2 additions & 2 deletions sphinx_automodapi/tests/example_module/nonascii.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__all__ = ['NonAscii']
__all__ = ['NonAsciiÄöüßő']


class NonAscii(object):
class NonAsciiÄöüßő(object):
def get_äöü(self):
"""
Return a string with common umlauts like äöüß
Expand Down
6 changes: 3 additions & 3 deletions sphinx_automodapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ def find_autosummary_in_lines_for_automodsumm(lines, module=None, filename=None)
"""
autosummary_re = re.compile(r'^(\s*)\.\.\s+autosummary::\s*')
automodule_re = re.compile(
r'^\s*\.\.\s+automodule::\s*([A-Za-z0-9_.]+)\s*$')
r'^\s*\.\.\s+automodule::\s*([A-Za-zäüöÄÜÖßő0-9_.]+)\s*$')
module_re = re.compile(
r'^\s*\.\.\s+(current)?module::\s*([a-zA-Z0-9_.]+)\s*$')
autosummary_item_re = re.compile(r'^\s+(~?[_a-zA-Z][a-zA-Z0-9_.]*)\s*.*?')
r'^\s*\.\.\s+(current)?module::\s*([a-zA-ZäüöÄÜÖßő0-9_.]+)\s*$')
autosummary_item_re = re.compile(r'^\s+(~?[_a-zA-ZäüöÄÜÖßő][a-zA-ZäüöÄÜÖßő0-9_.]*)\s*.*?')
toctree_arg_re = re.compile(r'^\s+:toctree:\s*(.*?)\s*$')
template_arg_re = re.compile(r'^\s+:template:\s*(.*?)\s*$')
inherited_members_arg_re = re.compile(r'^\s+:inherited-members:\s*$')
Expand Down