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

Fix readme render #607

Merged
merged 3 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ env:
# Make sure that installation does not fail
- SETUP_CMD='install'
# Make sure README will display properly on pypi
- PIP_DEPENDENCIES='collective.checkdocs pygments' SETUP_CMD='checkdocs'
- PIP_DEPENDENCIES='twine' TWINE_CHECK=1
- PYTHON_VERSION=3.5 SETUP_CMD='test'
- PYTHON_VERSION=3.6 SETUP_CMD='test'
- PYTHON_VERSION=3.7 PYTEST_VERSION=3.8 SETUP_CMD='test'
Expand Down Expand Up @@ -89,7 +89,12 @@ install:
- python setup.py install

script:
- $MAIN_CMD $SETUP_CMD
- if [[ $TWINE_CHECK ]]; then
python setup.py build sdist;
twine check dist/*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, this is diabolical (in a good way)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😈

else
$MAIN_CMD $SETUP_CMD;
fi

after_success:
# If coveralls.io is set up for this package, uncomment the line
Expand Down
10 changes: 9 additions & 1 deletion setup_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import sys
import codecs
import subprocess as sp

import ah_bootstrap
Expand Down Expand Up @@ -84,9 +85,16 @@ def read_metadata(config_filename):


def read_readme(readme_filename):
with open(readme_filename) as ff:
with codecs.open(readme_filename, encoding='utf8') as ff:
lines = ff.read().splitlines()

# Skip lines that contain raw HTML markup
lines = lines[:4] + lines[26:]
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a bit dangerous - what if someone else makes the README and doesn't realize they need to update this file?

Maybe instead look for the .. raw:: html marker, and then skip all consecutive following lines that are indented (or empty)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you're absolutely right. We should do something smarter like that in the long term but for the sake of this bug fix I'm going to leave it alone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also the point of the twine check above is that it should catch any such changes that lead to invalid output, but we're in agreement.


# Turn the header comment into a real header
lines = lines[1:]
lines[0:2] = [x.strip() for x in lines[0:2]]

# Fix hyperlink targets so that the README displays properly on pypi
label_re = re.compile(r'^\.\.\s+_(\w|-)+$')
for i, line in enumerate(lines):
Expand Down