Skip to content

Conversation

@rwb27
Copy link
Collaborator

@rwb27 rwb27 commented Oct 30, 2025

This fixes a few issues with the documentation, mostly minor formatting stuff. It also adds a new docs tool that enables :deco: to put the @ in front of decorators.

This follows on from #194 and should be reviewed after that one is merged - currently this looks like there are a lot more changes than there really are!

@barecheck
Copy link

barecheck bot commented Oct 30, 2025

@rwb27 rwb27 force-pushed the docs-tidy-after-dropping-dependencies branch from e915ef8 to c9bfd2e Compare October 30, 2025 13:42
@julianstirling
Copy link
Contributor

@rwb27 Does this have more commits that were not merged with #194?

There was a bad indent in the properties module level docstring, and a few imports that confused Sphinx when making cross-references.

I've moved an exception and tweaked the way Thing._thing_server_interface is declared to improve the docs: this should not change any code.
ThingServerInterface is used as a type hint for `Thing._thing_server_interface`. It was previously imported with an `if TYPE_CHECKING` guard, but as I've now explicitly type hinted and documented that attribute, any time `get_type_hints` is called on a `Thing` subclass (which
is every time one is defined) it will cause an error.

I've now imported it unconditionally, which fixes the problem. This does not cause any interdependency issues, as `thing_server_interface` has few onward dependencies.
This shouldn't be duplicated in `conf.py`.
I've converted quite a few links to other pages in the docs, now that they exist. I think redirecting people to the WoT page all the time is causing confusion.
This was left-over old syntax that didn't get migrated.
The "running LabThings" page in the tutorial didn't mention that it was possible
to start a ThingServer from within Python.
I have now mentioned this on that page, with a link to an example.
@rwb27 rwb27 force-pushed the docs-tidy-after-dropping-dependencies branch from 0cf53bb to ed2e66f Compare November 15, 2025 09:47
@rwb27
Copy link
Collaborator Author

rwb27 commented Nov 15, 2025

@rwb27 Does this have more commits that were not merged with #194?

yes: this follows on from 194. As it's just improvements to documentation, I thought it was probably best to keep it separate, #194 was huge enough already...

@rwb27 rwb27 requested a review from julianstirling November 15, 2025 09:50
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "labthings-fastapi"
copyright = "2024, Richard Bowman"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
copyright = "2024, Richard Bowman"
copyright = "2025, Richard Bowman"

Copy link
Contributor

@julianstirling julianstirling left a comment

Choose a reason for hiding this comment

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

A couple of teeny things and a suggested date update.

-------

OpenAPI_ is a standard way to describe an HTTP interface. It lists all of the possible HTTP requests that may be made, along with a description of each one, and a description of the possible responses.
`OpenAPI <https://www.openapis.org/>` is a standard way to describe an HTTP interface. It lists all of the possible HTTP requests that may be made, along with a description of each one, and a description of the possible responses.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth adding something to the effect that the OpenAPI docs for any LabThings fastapi server will be hosted at blahblah/docs.

Descriptors are a way to intercept attribute access on an object. By default, attributes of an object are just variables - so an object called ``foo`` might have an attribute called ``bar``, and you may read its value with ``foo.bar``, write its value with ``foo.bar = "baz"``, and delete the attribute with ``del foo.bar``. If ``foo`` is a descriptor, Python will call the ``__get__`` method of that descriptor when it's read and the ``__set__`` method when it's written to. You have quite probably used a descriptor already, because the built-in `~builtins.property` creates a descriptor object: that's what runs your getter method when the property is accessed. The descriptor protocol is described with plenty of examples in the `Descriptor Guide`_ in the Python documentation.

In LabThings-FastAPI, descriptors are used to implement :ref:`wot_actions` and :ref:`wot_properties` on `.Thing` subclasses. The intention is that these will function like standard Python methods and properties, but will also be available over HTTP, along with automatic documentation in the :ref:`wot_td` and OpenAPI documents.
In LabThings-FastAPI, descriptors are used to implement :ref:`actions` and :ref:`properties` on `.Thing` subclasses. The intention is that these will function like standard Python methods and properties, but will also be available over HTTP, along with :ref:`gen_docs`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably need to see it in context in the docs, but probably worth making a note that no one except someone developing LabThings should need to understand descriptors so mentioning them should be reserved for developer docs

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.

3 participants