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] Fix title detection logic. #356

Merged
merged 1 commit into from Feb 27, 2018

Conversation

Projects
None yet
3 participants
@lesteve
Contributor

lesteve commented Feb 26, 2018

I tried using sphinx-gallery from master in scikit-learn and I found that #345 introduces a regression in a edge case, where the title starts with a space, i.e. your example starts with something like this:

"""
======================
        The title
======================
"""

I also added more tests for extract_intro_and_title. The detection is based on regex and I feel is as good as the previous one. I tried a docutils based solution using docutils.core.publish_doctree (I am guessing we could even check that the first paragraph is a title if we go this way) but I did not get anywhere convincing in a reasonable amount of time.

Note: to make a long story short, the title found by sphinx-gallery was empty before #345 but in practice this does not matter at all (except if you use ordering by title). The title for each example in the gallery is generated automatically by sphinx from a :ref: to the automatically added reference into the example rst.

Fix title detection logic.
The edge case was when the title starts with a space.

Add more tests for extract_intro_and_title.

@lesteve lesteve force-pushed the lesteve:fix-empty-title branch from 32c5574 to c036a12 Feb 26, 2018

@lesteve lesteve changed the title from Fix title detection logic. to [MRG] Fix title detection logic. Feb 26, 2018

@larsoner

This comment has been minimized.

Contributor

larsoner commented Feb 26, 2018

Argh sorry for the regression. Changes and tests LGTM

@codecov-io

This comment has been minimized.

codecov-io commented Feb 26, 2018

Codecov Report

Merging #356 into master will increase coverage by 0.15%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #356      +/-   ##
==========================================
+ Coverage   91.93%   92.08%   +0.15%     
==========================================
  Files          27       27              
  Lines        1834     1844      +10     
==========================================
+ Hits         1686     1698      +12     
+ Misses        148      146       -2
Impacted Files Coverage Δ
sphinx_gallery/gen_rst.py 95.66% <100%> (+0.02%) ⬆️
sphinx_gallery/tests/test_gen_rst.py 98.61% <100%> (+0.05%) ⬆️
sphinx_gallery/docs_resolv.py 70.45% <0%> (+0.9%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 922671b...c036a12. Read the comment docs.

@lesteve

This comment has been minimized.

Contributor

lesteve commented Feb 27, 2018

OK thanks for the review @larsoner! Let's merge this one then.

@lesteve lesteve merged commit df55e22 into sphinx-gallery:master Feb 27, 2018

5 checks passed

ci/circleci Your tests passed on CircleCI!
Details
codecov/patch 100% of diff hit (target 91.93%)
Details
codecov/project 92.08% (+0.15%) compared to 922671b
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@lesteve lesteve deleted the lesteve:fix-empty-title branch Feb 27, 2018

@lesteve

This comment has been minimized.

Contributor

lesteve commented Feb 27, 2018

Argh sorry for the regression.

Forgot to say actually, it was more helping a bug to come out of the closet than a regression per se ;-) !

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