-
Notifications
You must be signed in to change notification settings - Fork 4
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
jupyter and ipython code-blocks #2
Conversation
Add support for >>> blocks outside of code-blocks Add ipython as identifier for python blocks Signed-off-by: Fabian Haase <[email protected]>
flake8_rst/rst.py
Outdated
|
||
def find_sourcecode(src): | ||
for match in RST_RE.finditer(src): | ||
origin_code = match.group('code') | ||
for expression in [RST_RE, ANCHOR_RE]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just create many matches, without extend indent?
for example:
matches = (match for expression in EXPRESSIONS for match in expression.finditer(src)]
for match in matches:
# old code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea, much cleaner.
tests/data/example_10.py
Outdated
|
||
>>> print('This line is highlighted.') | ||
This line is highlighted. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add newline at end of file plz.
@@ -3,13 +3,14 @@ | |||
|
|||
RST_RE = re.compile( | |||
r'(?P<before>' | |||
r'^(?P<indent> *)\.\. (code-block|sourcecode):: (python|pycon)\n' | |||
r'^(?P<indent> *)\.\. (code-block|sourcecode|ipython):: (python|pycon)\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If i read properly, ipython directive use without (python|pycon)
And ipython console output contain square brackets, without >>>
, how does it work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I've been a little bit too enthusiastic, however in pandas they use directives like
.. ipython:: python
followed by plain python code. [with some roles like :suppress: sometimes]
These cases would be covered as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okey
Signed-off-by: Fabian Haase <[email protected]>
a73b619
to
7ca2de2
Compare
Thanks |
Add support for >>> blocks outside of code-blocks
Add ipython as identifier for python blocks