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

Doctests #385

Merged
merged 8 commits into from
Jul 23, 2024
Merged

Doctests #385

merged 8 commits into from
Jul 23, 2024

Conversation

Erotemic
Copy link
Contributor

First off, thank you for the library, it is a joy to use.

I was looking at the docstr for pylatex.Document in IPython and I found myself wishing that it had an example of a minimal use-case. I was able to look at the read the docs to get what I needed, but it would have been faster if it was builtin to the docstring itself. So I added a doctest that give a "hello world" example.

You'll note there I also added a "demo" section that gives a command line that will invoke the doctest, as well as a section at the end which uses my xdev package to actually pop the open the generated document for the user in whatever the default pdf program is. I think these are nice, but also not strictly necessary and it does require an extra dependency if you actually want to execute the doctest, so it could be paired down if desired.

However, I noticed that there were other doctests in the package, but it seems like they are never being run in CI and many of them are out of data and display incorrect results. I went through and fixed these. To ensure these don't break again I added the xdoctest package as a test-time dependency and included it in the testall.sh script, so now doctests will be run with the unit tests when invoking pytest. I also added a section to the pyproject.toml that does "the right thing" when the users just runs pytest in the repo root. There was also a minor issue with pytest attempting to pickup a __pycache__ directory that I fixed.

Lastly, there were a few deprecation warnings I saw in the test result. np.matrix is deprecated, so I replaced it with np.array. Also there were some backslashes that were not escaped correctly in two test files that I fixed.

Diff should be fairly clean and reviewable. Let me know what you think / if there are questions.

@JelteF
Copy link
Owner

JelteF commented Jul 23, 2024

Thank you for the work on this. I updated the github actions file so that it would also run CI for your PR. There seems to be some issue with your docstring though.

@Erotemic
Copy link
Contributor Author

Looks like sphinx doesn't like the "Demo" tag I added, which I was iffy on anyway, so I just removed it. I think it will work now.

@JelteF JelteF merged commit 3b19b9e into JelteF:master Jul 23, 2024
0 of 6 checks passed
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