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

[Documentation Code Camp] docstrings for emitted signals #866

Open
wants to merge 21 commits into
base: develop
Choose a base branch
from

Conversation

meguiraun
Copy link
Contributor

Initial work for documenting emitted signals. I initially focused on the abstract classes (not all done yet 🤪)

Example output:
image

@meguiraun meguiraun requested a review from beteva March 14, 2024 13:52
@fabcor-maxiv
Copy link
Contributor

Wouldn't it make more sense to document the emitted signals at the class level rather than at the method level?

If I use an actuator I want to know what signals it emits and when (under what circumstances, i.e. what is the meaning of the signal), but I do not need to know which of the actuator's methods actually emits the signal, do I?

And same thing, if I want to implement a new (concrete) actuator, I want to know what signals my actuator should emit, but I will choose which methods will actually emit those signals.

cc @elmjag

@beteva
Copy link
Member

beteva commented Mar 14, 2024

@meguiraun thanks for the work. Good start. There is one slight problem - I think AbstractAperture is an obsolete class, There will be very soon a new PR to handle aperture test and mock up, but they inherit from AbstractNState. In this context, would you mind if we see together which are the obsolete abstract classes.
@fabcor-maxiv I guess it is all right if we document the signals on the class level only. Actually this is the case right now, but certainly needs a bit of explanation which signal means what.

Maybe we should make a general signals documentation file, which lists all the "standard" signals, like valueChanged, limitsChanges, stateChanged, specificStateChanged, as well as the methods defined in BaseHardwareObjects.py - the emit method (namely its signature in order to explain how to emit a signal) and the force_emit_signals method, available for overloading . If we go for this, than we could explain the usage of these signals and in the classes only mention which are the emitted signals, and only document if there are other signals, specific for the class. What do you think?

@rhfogh
Copy link
Collaborator

rhfogh commented Mar 14, 2024

I agree with @beteva - The biggest need is what are the general kinds of signals that are used to tie the application together, where they come from, and what they do. In a way the biggest question is not so much 'which signals does this class emit' but 'which signals should I listen for' and 'which signals do I need to emit in my own class?'.

@meguiraun
Copy link
Contributor Author

okey, I see your point. I will leave the methods out.

yes, totally agree with a general documentation page (why, where in code are coming, some basic example, etc.), I had it in mind but I thought to start with documenting the code

@meguiraun
Copy link
Contributor Author

  1. Added a new md with signal documentation, very early, please @beteva @rhfogh have a look, and if you feel so commit any improvement
  2. Updated, let me know if the "new" AbstracActuator class documentation is ok:
image

Copy link
Contributor

@fabcor-maxiv fabcor-maxiv left a comment

Choose a reason for hiding this comment

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

I do not think there is a BaseHardwareObject class. So I replaced with HardwareObject. But in most cases what we talk about is actually in the HardwareObjectMixin.

I tried the Sphinx/docutils cross-reference roles, we'll see if we get better links.

In principle we should be able to configure Sphinx to keep a copy of the source code, so that we can have links to source code in the documentation (not links to GitHub).

And in general, not only for (Sphinx) documentation, we should avoid links to a branch, but use permalinks that link to a specific commit.

docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
@fabcor-maxiv
Copy link
Contributor

In many of the modified docstrings, it feels like adding the correct type hints would be nearly as efficient (especially for the return values).

@rhfogh
Copy link
Collaborator

rhfogh commented Mar 18, 2024

@fabcor-maxiv HardwareObjectMixin woudl be the right choice throughout. HardwareObjects inherit from either HardwareObject or HardwareObjectYaml, but both inherit from HardwareObjectMixin,.

@meguiraun meguiraun force-pushed the signal_documentation branch from 1494594 to a4cf60b Compare March 19, 2024 07:44
@meguiraun
Copy link
Contributor Author

preview in https://mxcubecore--866.org.readthedocs.build/en/866/dev/hwobj_signals.html

@beteva
Copy link
Member

beteva commented Mar 20, 2024

Very good job @meguiraun 👍
The device and the equipment signals are definitely deprecated. Quite some time ago there was a decision not to use Device and Equipment class any more.
You are right, we should remove the update signal and only use valueChanged.
You can also remove the xrf related signals - in my WIP for xrf I've changed them all to stateChanged

@marcus-oscarsson
Copy link
Member

Well done ! very nice !. As Antonia already pointed out, we should really start to remove the Device and Equipment classes.

@meguiraun meguiraun mentioned this pull request Mar 20, 2024
@meguiraun
Copy link
Contributor Author

while the signals are still there, I simply marked as deprecated.
Also added queue and diffractometer

docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
docs/source/dev/hwobj_signals.md Outdated Show resolved Hide resolved
mxcubecore/HardwareObjects/abstract/AbstractAperture.py Outdated Show resolved Hide resolved
mxcubecore/HardwareObjects/abstract/AbstractCollect.py Outdated Show resolved Hide resolved
mxcubecore/HardwareObjects/abstract/AbstractCollect.py Outdated Show resolved Hide resolved
mxcubecore/HardwareObjects/abstract/AbstractCollect.py Outdated Show resolved Hide resolved
Copy link
Member

@beteva beteva left a comment

Choose a reason for hiding this comment

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

Very nice.
Apparently we need changes in many python files for better documentation. I suggest we see together with the other developers who does what, but I like the class description you've made for AbstractActuator. We should follow the same way.

@beteva beteva changed the title docstrings for emitted signals [Documentation Code Camp] docstrings for emitted signals Mar 21, 2024
@meguiraun
Copy link
Contributor Author

AbstractBeam with docstrings in class here
AbstracActuator with docstrings outside class here

I can remove all changes to the abstract classes if it makes the other PR easier to handle

ping @beteva

@fabcor-maxiv
Copy link
Contributor

AbstractBeam with docstrings in class here
AbstracActuator with docstrings outside class here

For me, this belongs in the class docstring : )

@meguiraun
Copy link
Contributor Author

AbstractBeam with docstrings in class here
AbstracActuator with docstrings outside class here

For me, this belongs in the class docstring : )

I think same way, it seems its place

@beteva
Copy link
Member

beteva commented Mar 22, 2024

@meguiraun, agree the best place is the class docstrings.

@marcus-oscarsson
Copy link
Member

Hey @meguiraun, do you have an update on this one, it seemed almost done ?

@meguiraun
Copy link
Contributor Author

completely lost track of this one... so sorry...

If people are happy I am also happy. Not all the hwobjs are covered tough

@fabcor-maxiv
Copy link
Contributor

Not all checks are successful. After this is fixed, I think it is fine to merge. And then I might do follow-ups as I had already started in #947.

meguiraun and others added 17 commits August 16, 2024 10:52
Co-authored-by: fabcor <[email protected]>

Update docs/source/dev/hwobj_signals.md

Co-authored-by: fabcor <[email protected]>

Update docs/source/dev/hwobj_signals.md

Co-authored-by: fabcor <[email protected]>

Update docs/source/dev/hwobj_signals.md

Co-authored-by: fabcor <[email protected]>

Update docs/source/dev/hwobj_signals.md

Co-authored-by: fabcor <[email protected]>

Update docs/source/dev/hwobj_signals.md

Co-authored-by: fabcor <[email protected]>

Update docs/source/dev/hwobj_signals.md

Co-authored-by: fabcor <[email protected]>

Update docs/source/dev/hwobj_signals.md

Co-authored-by: fabcor <[email protected]>

Update docs/source/dev/hwobj_signals.md

Co-authored-by: fabcor <[email protected]>
Co-authored-by: Axel Bocciarelli <[email protected]>
@meguiraun meguiraun force-pushed the signal_documentation branch from 843d546 to 26b2d68 Compare August 16, 2024 08:52
@meguiraun
Copy link
Contributor Author

all checks are green now!

@marcus-oscarsson
Copy link
Member

Sorry my mistake. I must have missed the last comments, was this ready to be merged ?

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.

7 participants