Skip to content

Commit e506fce

Browse files
authored
sphinx-lint (#1142)
* Testing sphinx-lint. * Add sphinx-lint to pre-commit-config, tox, and github workflow. * Add self to AUTHORS.
1 parent 4a9039e commit e506fce

File tree

10 files changed

+51
-38
lines changed

10 files changed

+51
-38
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ repos:
2525
hooks:
2626
- id: flake8
2727
exclude: ^(oauth2_provider/migrations/|tests/migrations/)
28+
- repo: https://github.com/sphinx-contrib/sphinx-lint
29+
rev: v0.3
30+
hooks:
31+
- id: sphinx-lint

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Jim Graham
4444
Jonas Nygaard Pedersen
4545
Jonathan Steffan
4646
Jozef Knaperek
47+
Julien Palard
4748
Jun Zhou
4849
Kristian Rune Larsen
4950
Michael Howitz

docs/glossary.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ Glossary
3939

4040
Refresh Token
4141
A token the authorization server may issue to clients and can be swapped for a brand new access token, without
42-
repeating the authorization process. It has no expire time.
42+
repeating the authorization process. It has no expire time.

docs/management_commands.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,27 @@ The ``createapplication`` management command provides a shortcut to create a new
3535
.. code-block:: sh
3636
3737
usage: manage.py createapplication [-h] [--client-id CLIENT_ID] [--user USER] [--redirect-uris REDIRECT_URIS]
38-
[--client-secret CLIENT_SECRET] [--name NAME] [--skip-authorization] [--version] [-v {0,1,2,3}]
39-
[--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color]
40-
[--skip-checks]
41-
client_type authorization_grant_type
38+
[--client-secret CLIENT_SECRET] [--name NAME] [--skip-authorization] [--version] [-v {0,1,2,3}]
39+
[--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color]
40+
[--skip-checks]
41+
client_type authorization_grant_type
4242
4343
Shortcut to create a new application in a programmatic way
4444
4545
positional arguments:
4646
client_type The client type, can be confidential or public
4747
authorization_grant_type
48-
The type of authorization grant to be used
48+
The type of authorization grant to be used
4949
5050
optional arguments:
5151
-h, --help show this help message and exit
5252
--client-id CLIENT_ID
53-
The ID of the new application
53+
The ID of the new application
5454
--user USER The user the application belongs to
5555
--redirect-uris REDIRECT_URIS
56-
The redirect URIs, this must be a space separated string e.g 'URI1 URI2'
56+
The redirect URIs, this must be a space separated string e.g 'URI1 URI2'
5757
--client-secret CLIENT_SECRET
58-
The secret for this application
58+
The secret for this application
5959
--name NAME The name this application
6060
--skip-authorization The ID of the new application
6161
...

docs/oidc.rst

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -249,38 +249,39 @@ our custom validator. It takes one of two forms:
249249

250250
The first form gets passed a request object, and should return a dictionary
251251
mapping a claim name to claim data::
252+
252253
class CustomOAuth2Validator(OAuth2Validator):
253-
# Set `oidc_claim_scope = None` to ignore scopes that limit which claims to return,
254-
# otherwise the OIDC standard scopes are used.
254+
# Set `oidc_claim_scope = None` to ignore scopes that limit which claims to return,
255+
# otherwise the OIDC standard scopes are used.
255256

256257
def get_additional_claims(self, request):
257-
return {
258-
"given_name": request.user.first_name,
259-
"family_name": request.user.last_name,
260-
"name": ' '.join([request.user.first_name, request.user.last_name]),
261-
"preferred_username": request.user.username,
262-
"email": request.user.email,
263-
}
258+
return {
259+
"given_name": request.user.first_name,
260+
"family_name": request.user.last_name,
261+
"name": ' '.join([request.user.first_name, request.user.last_name]),
262+
"preferred_username": request.user.username,
263+
"email": request.user.email,
264+
}
264265

265266

266267
The second form gets no request object, and should return a dictionary
267268
mapping a claim name to a callable, accepting a request and producing
268269
the claim data::
269270
class CustomOAuth2Validator(OAuth2Validator):
270-
# Extend the standard scopes to add a new "permissions" scope
271-
# which returns a "permissions" claim:
272-
oidc_claim_scope = OAuth2Validator.oidc_claim_scope
273-
oidc_claim_scope.update({"permissions": "permissions"})
274-
275-
def get_additional_claims(self):
276-
return {
277-
"given_name": lambda request: request.user.first_name,
278-
"family_name": lambda request: request.user.last_name,
279-
"name": lambda request: ' '.join([request.user.first_name, request.user.last_name]),
280-
"preferred_username": lambda request: request.user.username,
281-
"email": lambda request: request.user.email,
282-
"permissions": lambda request: list(request.user.get_group_permissions()),
283-
}
271+
# Extend the standard scopes to add a new "permissions" scope
272+
# which returns a "permissions" claim:
273+
oidc_claim_scope = OAuth2Validator.oidc_claim_scope
274+
oidc_claim_scope.update({"permissions": "permissions"})
275+
276+
def get_additional_claims(self):
277+
return {
278+
"given_name": lambda request: request.user.first_name,
279+
"family_name": lambda request: request.user.last_name,
280+
"name": lambda request: ' '.join([request.user.first_name, request.user.last_name]),
281+
"preferred_username": lambda request: request.user.username,
282+
"email": lambda request: request.user.email,
283+
"permissions": lambda request: list(request.user.get_group_permissions()),
284+
}
284285

285286

286287
Standard claim ``sub`` is included by default, to remove it override ``get_claim_dict``.

docs/rest-framework/permissions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@ The following is a minimal OAS declaration that shows the same required alternat
114114
to try it in the `swagger editor <https://editor.swagger.io>`_.
115115

116116
.. literalinclude:: openapi.yaml
117-
:language: YAML
117+
:language: YAML

docs/templates.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,4 +242,4 @@ This template gets passed the following template context variable:
242242

243243
.. important::
244244
To override successfully this template you should provide a form that posts to the same URL, example:
245-
``<form method="post" action="">``
245+
``<form method="post" action="">``

docs/tutorial/tutorial_05.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ We'll add ours now in ``tutorial/tasks.py``:
8383
8484
@shared_task
8585
def clear_tokens():
86-
from oauth2_provider.models import clear_expired
86+
from oauth2_provider.models import clear_expired
8787
88-
clear_expired()
88+
clear_expired()
8989
9090
Finally, update ``tutorial/__init__.py`` to make sure Celery gets loaded when the app starts up:
9191

docs/views/mixins.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ Mixins for Class Based Views
22
============================
33

44
.. automodule:: oauth2_provider.views.mixins
5-
:members:
5+
:members:

tox.ini

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ envlist =
33
flake8,
44
migrations,
55
docs,
6+
sphinxlint,
67
py{37,38,39}-dj22,
78
py{37,38,39,310}-dj32,
89
py{38,39,310}-dj40,
@@ -11,7 +12,7 @@ envlist =
1112
[gh-actions]
1213
python =
1314
3.7: py37
14-
3.8: py38, docs, flake8, migrations
15+
3.8: py38, docs, flake8, migrations, sphinxlint
1516
3.9: py39
1617
3.10: py310
1718

@@ -56,6 +57,12 @@ passenv =
5657
ignore_errors = true
5758
ignore_outcome = true
5859

60+
[testenv:sphinxlint]
61+
deps = sphinx-lint
62+
skip_install = True
63+
commands =
64+
sphinx-lint docs/
65+
5966
[testenv:{docs,livedocs}]
6067
basepython = python3.8
6168
changedir = docs

0 commit comments

Comments
 (0)