Add a @webapi_docs decorator to store docs on the function.

Review Request #14046 — Created July 17, 2024 and updated

Information

Djblets
release-6.x

Reviewers

This change adds a new decorator for us to use for attaching
public-facing documentation to HTTP methods, rather than putting it into
the docstring. This will let us have internal codebase docs in the docstring
instead, which is much more appropriate.

Used along with a change to our webapidocs Sphinx extension to pull this
data out.

Summary ID
Add a @webapi_docs decorator to store docs on the function.
This change adds a new decorator for us to use for attaching public-facing documentation to HTTP methods, rather than putting it into the docstring. This will let us have internal codebase docs in the docstring instead, which is much more appropriate. Testing Done: Used along with a change to our webapidocs Sphinx extension to pull this data out.
508cc109ab61c2198d80f6f3e225d2998ae4b37e
Description From Last Updated

Can you add a unit test in test_decorators.py for this, and make sure that other state from other decorators (including …

chipx86chipx86

Looked up how we handle type-safety decorators elsewhere. We use this pattern: _FuncT = TypeVar('_FuncT', bound=Callable[..., WebAPIResourceHandlerResult]) def my_decorator( params, …

chipx86chipx86

'djblets.webapi.resources.base.WebAPIResourceHandlerResult' imported but unused Column: 5 Error code: F401

reviewbotreviewbot

at least two spaces before inline comment Column: 34 Error code: E261

reviewbotreviewbot

line too long (80 > 79 characters) Column: 80 Error code: E501

reviewbotreviewbot
There are no open issues
maubin
  1. Ship It!
  2. 
      
chipx86
  1. 
      
  2. Show all issues

    Can you add a unit test in test_decorators.py for this, and make sure that other state from other decorators (including name, type hints, etc.) are retained?

  3. 
      
david
chipx86
  1. Code looks good, but all the cleanup changes makes it really hard to focus on what's relevant to this new unit test, and makes for more difficult code archaeology later. Possible to split this out?

  2. 
      
david
chipx86
  1. 
      
  2. djblets/webapi/decorators.py (Diff revision 3)
     
     
     
     
    Show all issues

    Looked up how we handle type-safety decorators elsewhere. We use this pattern:

    _FuncT = TypeVar('_FuncT', bound=Callable[..., WebAPIResourceHandlerResult])
    
    
    def my_decorator(
        params,
    ) -> Callable[[_FuncT], _FuncT]:
        def _dec(
            func: _FuncT,
        ) -> _FuncT:
            return ...
    
        return _dec
    

    That'll keep the function signature passed all the way through.

    1. Forgot how old this change was. There's a much better way now, with ParamSpec. I'll update this to us that.

  3. 
      
david
Review request changed
Commits:
Summary ID
Add a @webapi_docs decorator to store docs on the function.
This change adds a new decorator for us to use for attaching public-facing documentation to HTTP methods, rather than putting it into the docstring. This will let us have internal codebase docs in the docstring instead, which is much more appropriate. Testing Done: Used along with a change to our webapidocs Sphinx extension to pull this data out.
07ea9819d74c9280b46db50e336c0d144a2083b3
Add a @webapi_docs decorator to store docs on the function.
This change adds a new decorator for us to use for attaching public-facing documentation to HTTP methods, rather than putting it into the docstring. This will let us have internal codebase docs in the docstring instead, which is much more appropriate. Testing Done: Used along with a change to our webapidocs Sphinx extension to pull this data out.
065a0e9933773e598016c944530249ee14de5cf6
Diff:

Revision 4 (+158 -18)

Show changes

djblets/webapi/decorators.py
djblets/webapi/tests/test_decorators.py

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

david
Review request changed
Commits:
Summary ID
Add a @webapi_docs decorator to store docs on the function.
This change adds a new decorator for us to use for attaching public-facing documentation to HTTP methods, rather than putting it into the docstring. This will let us have internal codebase docs in the docstring instead, which is much more appropriate. Testing Done: Used along with a change to our webapidocs Sphinx extension to pull this data out.
065a0e9933773e598016c944530249ee14de5cf6
Add a @webapi_docs decorator to store docs on the function.
This change adds a new decorator for us to use for attaching public-facing documentation to HTTP methods, rather than putting it into the docstring. This will let us have internal codebase docs in the docstring instead, which is much more appropriate. Testing Done: Used along with a change to our webapidocs Sphinx extension to pull this data out.
5fbccfd8d8802402f4f2a4a6ecae1dfa444f74b7
Diff:

Revision 5 (+152 -18)

Show changes

djblets/webapi/decorators.py
djblets/webapi/tests/test_decorators.py

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

david
Review request changed
Commits:
Summary ID
Add a @webapi_docs decorator to store docs on the function.
This change adds a new decorator for us to use for attaching public-facing documentation to HTTP methods, rather than putting it into the docstring. This will let us have internal codebase docs in the docstring instead, which is much more appropriate. Testing Done: Used along with a change to our webapidocs Sphinx extension to pull this data out.
5fbccfd8d8802402f4f2a4a6ecae1dfa444f74b7
Add a @webapi_docs decorator to store docs on the function.
This change adds a new decorator for us to use for attaching public-facing documentation to HTTP methods, rather than putting it into the docstring. This will let us have internal codebase docs in the docstring instead, which is much more appropriate. Testing Done: Used along with a change to our webapidocs Sphinx extension to pull this data out.
508cc109ab61c2198d80f6f3e225d2998ae4b37e
Diff:

Revision 6 (+152 -18)

Show changes

djblets/webapi/decorators.py
djblets/webapi/tests/test_decorators.py

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
maubin
  1. Ship It!
  2. 
      
Loading...