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

[MRG] Build gallery when example has SyntaxError #177

Merged
merged 1 commit into from Dec 18, 2016

Conversation

Projects
None yet
3 participants
@Titan-C
Member

Titan-C commented Nov 27, 2016

As reported in #126 if an example has a SyntaxError gallery build
breaks. This provides the necessary changes to continue build and
raise an error at the end on the summary of errors

@@ -186,6 +186,8 @@ def extract_intro(filename):
""" Extract the first paragraph of module-level docstring. max:95 char"""
docstring, _ = get_docstring_and_rest(filename)

This comment has been minimized.

@lesteve

lesteve Nov 28, 2016

Contributor

My original idea was (untested so maybe there is a problem with it), just change get_docstring_and_rest to return "", full_content_of_the_file including docstring. Then you can run later the example normally and you don't have more code changes to do. Maybe we require an non empty docstring in which case just return something like "A SyntaxError happened while parsing the example" as the docstring.

@Titan-C Titan-C force-pushed the Titan-C:syntax branch 3 times, most recently from abb4349 to 31985fb Dec 17, 2016

Build gallery when example has SyntaxError
As reported in #126 if an example has a SyntaxError gallery build
breaks. This provides the necessary changes to continue build and
raise an error at the end on the summary of errors

@Titan-C Titan-C force-pushed the Titan-C:syntax branch from 31985fb to 498a548 Dec 17, 2016

@Titan-C Titan-C changed the title from [WIP] Build gallery when example has SyntaxError to MRG] Build gallery when example has SyntaxError Dec 17, 2016

@Titan-C Titan-C changed the title from MRG] Build gallery when example has SyntaxError to [MRG] Build gallery when example has SyntaxError Dec 17, 2016

@Titan-C

This comment has been minimized.

Member

Titan-C commented Dec 17, 2016

Rebased and comments addressed.

@lesteve

This comment has been minimized.

Contributor

lesteve commented Dec 18, 2016

Very nice, merging, thanks !

@lesteve lesteve merged commit f24c960 into sphinx-gallery:master Dec 18, 2016

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@@ -27,12 +34,16 @@ def get_docstring_and_rest(filename):
# can't use codecs.open(filename, 'r', 'utf-8') here b/c ast doesn't
# seem to work with unicode strings in Python2.7
# "SyntaxError: encoding declaration in Unicode string"
with open(filename, 'rb') as f:
content = f.read()
with open(filename, 'rb') as fid:

This comment has been minimized.

@lesteve

lesteve Dec 18, 2016

Contributor

Just curious, why fid, i.e. what does it stand for?

This comment has been minimized.

@Titan-C

Titan-C Dec 18, 2016

Member

fid is a name I constantly encounter, so I just took it as convention. The reason to change is that my linter is always complaining about single letter variables

This comment has been minimized.

@lesteve

lesteve Dec 18, 2016

Contributor

I have never seen fid for a file I have to say ... maybe it is more used in a C context where fopen returns the file identifier.

@GaelVaroquaux

This comment has been minimized.

Contributor

GaelVaroquaux commented Dec 18, 2016

@Titan-C Titan-C deleted the Titan-C:syntax branch Dec 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment