-
-
Notifications
You must be signed in to change notification settings - Fork 24
[WIP] Parsing docstrings too. #152
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
base: main
Are you sure you want to change the base?
Conversation
|
Here how it goes on friends projects: So there's one false positive in cpython, which is expected as cpython does not use rst in their docstring. I think this check could be opt-in, as using rst in docstrings may not be the default? Like |
|
Yes it worked nicely. I think one could either do an opt in or an opt out with I found a couple of false positives as well, but very good start. I will list them below I think one should not check for general Python strings or code and only check if they are in a real docstring. Everything else will not be rendered anyway with sphinx. It is probably not enough to grep only text between tripe quotes because there are also attribute annotations that will be rendered. for a function like class TestPlanarBaseChilds:
"""Tests for the AnalayseBase child classes."""
ignored_parameters = ["atomgroup", "wrap_compound"]
@pytest.mark.parametrize("Member", find_cls_members(AnalysisBase, ["maicos"]))
def test_parameters(self, Member):
"""Test if AnalysisBase paramaters exist in all modules."""
base_sig = inspect.signature(AnalysisBase)
mod_sig = inspect.signature(Member)
for param in base_sig.parameters.values():
if param.name in self.ignored_parameters:
continue
try:
mod_sig.parameters[param.name]
except KeyError as err:
raise KeyError(f"{param.name} is not a parameter of {Member}!") from errI just have a class docstring and get an error in the last line |
|
I added tests (cf. last commit) with your codes and I was not able to reproduce your issues. Can you provide tests reproducing your findings? |
That's what's this PR does: only docstrings. |
|
Yes, sorry I was confused because I got an error for a docstring that has an example code block """
>>> a = 1 # refers to the value of `a`
"""But I will add a test. |
|
I updated the one docstring with valid inline comments that should be valid. I am not allowed to push to your branch. I pasted my changes below: class Youpi:
"""Dielectric profile calculation
==============================
In the following example, we will show how to calculate the dielectric profiles as
described in :ref:`dielectric-explanations`.
Before producing trajectories to calculate dielectric profiles, you will need to
consider which information you will need and thus need to print out. The dielectric
profile calculators need unwrapped positions and charges of **all** charged atoms in
the system. Unwrapped refers to the fact that you will need either "repaired"
molecules (which in GROMACS ``trjconv`` with the ``-pbc mol`` option can do for you)
or you will
Examples are
.. code-block:: python
a = 1 # refers to the value of `a`
or
>>> b = 2 # refers to the value of `b`
""" |
closes #141