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

jupyter and ipython code-blocks #2

Merged
merged 2 commits into from
Oct 29, 2018
Merged

Conversation

FHaase
Copy link
Contributor

@FHaase FHaase commented Oct 24, 2018

Add support for >>> blocks outside of code-blocks
Add ipython as identifier for python blocks

Add support for >>> blocks outside of code-blocks
Add ipython as identifier for python blocks

Signed-off-by: Fabian Haase <[email protected]>

def find_sourcecode(src):
for match in RST_RE.finditer(src):
origin_code = match.group('code')
for expression in [RST_RE, ANCHOR_RE]:
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, much cleaner.


>>> print('This line is highlighted.')
This line is highlighted.
"""
Copy link
Collaborator

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'
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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]>
@kataev
Copy link
Collaborator

kataev commented Oct 29, 2018

Thanks

@kataev kataev merged commit 35a56c8 into flake8-docs:master Oct 29, 2018
@FHaase FHaase deleted the feature/jupyter branch November 13, 2018 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants