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

Python package setup and basic tests #44

Merged
merged 12 commits into from Mar 29, 2017
Merged

Python package setup and basic tests #44

merged 12 commits into from Mar 29, 2017

Conversation

lucaswiman
Copy link
Contributor

@lucaswiman lucaswiman commented Feb 11, 2017

@tabatkins This PR makes the following changes:

  • Adds a setup.py file and appropriate python packaging metadata. This should allow you to upload the file to pypi*, which would make it pip installable.
  • Makes some minor Python 3 compatibility fixes.
  • Adds some simple tests that run through the included examples and verify they're valid XML. This doesn't test the program logic much, but is better than nothing.
  • Adds support for the tox test runner to run tests against python 2.7, 3.4, 3.5 and 3.6, showing statement coverage reports after each test run:
---------- coverage: platform darwin, python 3.5.1-final-0 -----------
Name                   Stmts   Miss  Cover   Missing
----------------------------------------------------
railroad_diagrams.py     535    195    64%   25, 27, 50, 76-77, 87, 112-113, 136, 138, 177, 217-218, 239-258, 261-287, 292-295, 298-318, 321-395, 421-422, 486-512, 515-601, 622-623, 662-663, 668-669, 681-682, 687-688, 702-703, 716-717, 733-734, 747-748, 764-765, 776-777, 790-791, 799-806

This PR also does the following:

  • Adds __eq__ and a descriptive __repr__ method. I've found this makes working with the library much more user-friendly, and makes tests easier to write.
  • Adds a default <style> element so a separate stylesheet is not required to render the generated SVGs. Currently the SVGs are pretty broken without the default stylesheet, so I think inlining the CSS is the right way to go:
styled unstyled
screen shot 2017-02-11 at 12 24 45 am screen shot 2017-02-11 at 12 24 34 am

Thanks again for writing this library!


* Note: If you're unfamiliar with the upload process (which is a little confusing), I'd be happy to upload it for you, and transfer ownership of the pypi package to your pypi account. Otherwise, this is a good guide.

@lucaswiman
Copy link
Contributor Author

I've updated the python code to add a <style> element. Annoyingly, imagemagick can't even handle that, but it seems a much cleaner solution than inlining the CSS on each element. Users of this library can inline the CSS using a tool like premailer before passing them to those tools. I don't know Javascript very well, but I'd be happy to make a similar update to the Javascript code if you'd like.

The example HTML generated by the python script is here: https://jsfiddle.net/r4cs3wkd/

@tabatkins tabatkins merged commit 616901a into tabatkins:gh-pages Mar 29, 2017
@tabatkins
Copy link
Owner

Thanks for this work! I'll handle moving the style over to the JS port.

@lucaswiman lucaswiman deleted the setup.py branch March 30, 2017 01:16
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.

None yet

2 participants