Skip to content

Commit

Permalink
Autoformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
TiagoCavalcante committed Jun 23, 2021
1 parent f9db6f2 commit 99a0bf7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion mathicsscript/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_completions(
words = []

def word_matches(word: str) -> bool:
""" True when the word before the cursor matches. """
"""True when the word before the cursor matches."""

if self.match_middle:
return word_before_cursor in word
Expand Down
45 changes: 20 additions & 25 deletions rst2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,47 @@

import re


def yield_sphinx_only_markup(lines):
"""
:param file_inp: a `filename` or ``sys.stdin``?
:param file_out: a `filename` or ``sys.stdout`?`
"""
substs = [
## Selected Sphinx-only Roles.
# Selected Sphinx-only Roles.
#
(r':abbr:`([^`]+)`', r'\1'),
(r':ref:`([^`]+)`', r'`\1`_'),
(r':term:`([^`]+)`', r'**\1**'),
(r':dfn:`([^`]+)`', r'**\1**'),
(r':(samp|guilabel|menuselection):`([^`]+)`', r'``\2``'),


## Sphinx-only roles:
(r":abbr:`([^`]+)`", r"\1"),
(r":ref:`([^`]+)`", r"`\1`_"),
(r":term:`([^`]+)`", r"**\1**"),
(r":dfn:`([^`]+)`", r"**\1**"),
(r":(samp|guilabel|menuselection):`([^`]+)`", r"``\2``"),
# Sphinx-only roles:
# :foo:`bar` --> foo(``bar``)
# :a:foo:`bar` XXX afoo(``bar``)
#
#(r'(:(\w+))?:(\w+):`([^`]*)`', r'\2\3(``\4``)'),
(r':(\w+):`([^`]*)`', r'\1(``\2``)'),


## Sphinx-only Directives.
# (r'(:(\w+))?:(\w+):`([^`]*)`', r'\2\3(``\4``)'),
(r":(\w+):`([^`]*)`", r"\1(``\2``)"),
# Sphinx-only Directives.
#
(r'\.\. doctest', r'code-block'),
(r'\.\. plot::', r'.. '),
(r'\.\. seealso', r'info'),
(r'\.\. glossary', r'rubric'),
(r'\.\. figure::', r'.. '),


## Other
(r"\.\. doctest", r"code-block"),
(r"\.\. plot::", r".. "),
(r"\.\. seealso", r"info"),
(r"\.\. glossary", r"rubric"),
(r"\.\. figure::", r".. "),
# Other
#
(r'\|version\|', r'x.x.x'),
(r"\|version\|", r"x.x.x"),
]

regex_subs = [ (re.compile(regex, re.IGNORECASE), sub) for (regex, sub) in substs ]
regex_subs = [(re.compile(regex, re.IGNORECASE), sub) for (regex, sub) in substs]

def clean_line(line):
try:
for (regex, sub) in regex_subs:
line = regex.sub(sub, line)
except Exception as ex:
print("ERROR: %s, (line(%s)"%(regex, sub))
print("ERROR: %s, (line(%s)" % (regex, sub))
raise ex

return line
Expand Down

0 comments on commit 99a0bf7

Please sign in to comment.