-
Notifications
You must be signed in to change notification settings - Fork 30
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
Make code blocks in src/vector/_compute/*.py
parsable
#240
Comments
@Saransh-cpp were you thinking of things like simple examples to replace what Jim had added in PR #55? --- a/src/vector/_compute/lorentz/tau2.py
+++ b/src/vector/_compute/lorentz/tau2.py
@@ -4,10 +4,11 @@
# or https://github.com/scikit-hep/vector for details.
"""
-.. code-block:: python
+Example:
- @property
- Lorentz.tau2(self)
+ >>> import vector
+ >>> vector.obj(pt=3, phi=2, eta=1, mass=4).tau2
+ 16.0
"""
from __future__ import annotations or something else that extends instead of replaces? |
My initial thought was to replace the current examples with copy-pastable examples. Now that I think of it, the current examples are also very informative for vector's developers and users. Maybe we can do something like - .. code-block:: python
@property
Lorentz.tau2(self)
+Example:
+
+.. code-block:: python
+
+ >>> import vector
+ >>> vector.obj(pt=3, phi=2, eta=1, mass=4).tau2
+ 16.0 and let |
Can I work on this issue? |
I think that would be very helpful. Thank you! @Saransh-cpp, could you help @Akhil-Sharma30 get started? |
You don't need to "let it fail", just use Or you can avoid the >>>, I'm not wildly fond of adding characters that can't be copy-pasted for copy-paste examples. (Unless the code renderer can make those parts not copy-passable, sometimes they can). |
Yes, definitely! Sorry, I wasn't able to comment before. @Akhil-Sharma30 can you start with @henryiii's suggestion and open a new PR for changing some of the code blocks to
with |
Hi, I would like to work on this issue. But, I have a question-- why are we using So, my suggestion is:
Please LMK if my understanding is correct and if I should go ahead with the above approach. Thank you :) |
Before #545 (last week), all of the docstrings were being rendered in readthedocs, and they used ReST to do it. In that PR, I restricted the user-facing docs to just those that a user should be concerned about and anything that was rewritten was rewritten as Markdown, rather than ReST. I did not remove docstrings from classes and functions that used to be visible in readthedocs and now aren't—there's a linter that requires non-underscored classes and functions to have docstrings, and anyway, why remove good documentation? It no longer needs to be ReST-formatted because it's not being rendered in HTML, but I don't think there's any need to perform a campaign of removing ReST declarations. Since these are no longer rendered in readthedocs, they're explicitly expert-level documentation for developers going through the codebase, and experts can ignore some unnecessary ReST baggage. Unless, of course, removing them helps to make all of the documentation adhere to a format enforced by black. In that case, if you're wondering whether the ReST declarations need to be preserved: they do not need to be preserved. |
Thank you for replying @jpivarski ! I kept the |
Vector
usesblacken-docs
to prettify and format the docs. However, we use the-E
flag to ignore any errors present in the code blocks.Removing the
-E
option outputs the following errors -The hook -
vector/.pre-commit-config.yaml
Lines 75 to 80 in d4ad49e
These code blocks should ideally be parsable, and the
-E
option should be removedThe text was updated successfully, but these errors were encountered: