Skip to content

Commit fdd0594

Browse files
authored
docs: clean up and improve documentation (#1401)
1 parent 817eb40 commit fdd0594

17 files changed

+139
-160
lines changed

docs/advanced_topics.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Django OAuth Toolkit lets you extend the AbstractApplication model in a fashion
3131
custom user models.
3232

3333
If you need, let's say, application logo and user agreement acceptance field, you can do this in
34-
your Django app (provided that your app is in the list of the INSTALLED_APPS in your settings
34+
your Django app (provided that your app is in the list of the ``INSTALLED_APPS`` in your settings
3535
module)::
3636

3737
from django.db import models
@@ -44,11 +44,11 @@ module)::
4444
Then you need to tell Django OAuth Toolkit which model you want to use to represent applications.
4545
Write something like this in your settings module::
4646

47-
OAUTH2_PROVIDER_APPLICATION_MODEL='your_app_name.MyApplication'
47+
OAUTH2_PROVIDER_APPLICATION_MODEL = 'your_app_name.MyApplication'
4848

4949
Be aware that, when you intend to swap the application model, you should create and run the
50-
migration defining the swapped application model prior to setting OAUTH2_PROVIDER_APPLICATION_MODEL.
51-
You'll run into models.E022 in Core system checks if you don't get the order right.
50+
migration defining the swapped application model prior to setting ``OAUTH2_PROVIDER_APPLICATION_MODEL``.
51+
You'll run into ``models.E022`` in Core system checks if you don't get the order right.
5252

5353
You can force your migration providing the custom model to run in the right order by
5454
adding::
@@ -61,15 +61,15 @@ to the migration class.
6161

6262
That's all, now Django OAuth Toolkit will use your model wherever an Application instance is needed.
6363

64-
**Notice:** `OAUTH2_PROVIDER_APPLICATION_MODEL` is the only setting variable that is not namespaced, this
64+
.. note:: ``OAUTH2_PROVIDER_APPLICATION_MODEL`` is the only setting variable that is not namespaced, this
6565
is because of the way Django currently implements swappable models.
66-
See issue #90 (https://github.com/jazzband/django-oauth-toolkit/issues/90) for details
66+
See `issue #90 <https://github.com/jazzband/django-oauth-toolkit/issues/90>`_ for details.
6767

6868
Multiple Grants
6969
~~~~~~~~~~~~~~~
7070

7171
The default application model supports a single OAuth grant (e.g. authorization code, client credentials). If you need
72-
applications to support multiple grants, override the `allows_grant_type` method. For example, if you want applications
72+
applications to support multiple grants, override the ``allows_grant_type`` method. For example, if you want applications
7373
to support the authorization code *and* client credentials grants, you might do the following::
7474

7575
from oauth2_provider.models import AbstractApplication
@@ -86,12 +86,12 @@ Skip authorization form
8686

8787
Depending on the OAuth2 flow in use and the access token policy, users might be prompted for the
8888
same authorization multiple times: sometimes this is acceptable or even desirable but other times it isn't.
89-
To control DOT behaviour you can use the `approval_prompt` parameter when hitting the authorization endpoint.
89+
To control DOT behaviour you can use the ``approval_prompt`` parameter when hitting the authorization endpoint.
9090
Possible values are:
9191

92-
* `force` - users are always prompted for authorization.
92+
* ``force`` - users are always prompted for authorization.
9393

94-
* `auto` - users are prompted only the first time, subsequent authorizations for the same application
94+
* ``auto`` - users are prompted only the first time, subsequent authorizations for the same application
9595
and scopes will be automatically accepted.
9696

9797
Skip authorization completely for trusted applications
@@ -109,7 +109,7 @@ Overriding views
109109
================
110110

111111
You may want to override whole views from Django OAuth Toolkit, for instance if you want to
112-
change the login view for unregistred users depending on some query params.
112+
change the login view for unregistered users depending on some query params.
113113

114114
In order to do that, you need to write a custom urlpatterns
115115

docs/contributing.rst

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This is a `Jazzband <https://jazzband.co>`_ project. By contributing you agree t
1212
Setup
1313
=====
1414

15-
Fork `django-oauth-toolkit` repository on `GitHub <https://github.com/jazzband/django-oauth-toolkit>`_ and follow these steps:
15+
Fork ``django-oauth-toolkit`` repository on `GitHub <https://github.com/jazzband/django-oauth-toolkit>`_ and follow these steps:
1616

1717
* Create a virtualenv and activate it
1818
* Clone your repository locally
@@ -55,14 +55,14 @@ is a better way to structure the code so that it is more readable.
5555
Documentation
5656
=============
5757

58-
You can edit the documentation by editing files in ``docs/``. This project
58+
You can edit the documentation by editing files in :file:`docs/`. This project
5959
uses sphinx to turn ``ReStructuredText`` into the HTML docs you are reading.
6060

6161
In order to build the docs in to HTML, you can run::
6262

6363
tox -e docs
6464

65-
This will build the docs, and place the result in ``docs/_build/html``.
65+
This will build the docs, and place the result in :file:`docs/_build/html`.
6666
Alternatively, you can run::
6767

6868
tox -e livedocs
@@ -89,7 +89,7 @@ For example, to add Deutsch::
8989
cd oauth2_provider
9090
django-admin makemessages --locale de
9191

92-
Then edit ``locale/de/LC_MESSAGES/django.po`` to add your translations.
92+
Then edit :file:`locale/de/LC_MESSAGES/django.po` to add your translations.
9393

9494
When deploying your app, don't forget to compile the messages with::
9595

@@ -108,16 +108,16 @@ And, if a new migration is needed, use::
108108

109109
django-admin makemigrations --settings tests.mig_settings
110110

111-
Auto migrations frequently have ugly names like `0004_auto_20200902_2022`. You can make your migration
112-
name "better" by adding the `-n name` option::
111+
Auto migrations frequently have ugly names like ``0004_auto_20200902_2022``. You can make your migration
112+
name "better" by adding the ``-n name`` option::
113113

114114
django-admin makemigrations --settings tests.mig_settings -n widget
115115

116116

117117
Pull requests
118118
=============
119119

120-
Please avoid providing a pull request from your `master` and use **topic branches** instead; you can add as many commits
120+
Please avoid providing a pull request from your ``master`` and use **topic branches** instead; you can add as many commits
121121
as you want but please keep them in one branch which aims to solve one single issue. Then submit your pull request. To
122122
create a topic branch, simply do::
123123

@@ -129,7 +129,7 @@ When you're ready to submit your pull request, first push the topic branch to yo
129129
git push origin fix-that-issue
130130

131131
Now you can go to your repository dashboard on GitHub and open a pull request starting from your topic branch. You can
132-
apply your pull request to the `master` branch of django-oauth-toolkit (this should be the default behaviour of GitHub
132+
apply your pull request to the ``master`` branch of django-oauth-toolkit (this should be the default behaviour of GitHub
133133
user interface).
134134

135135
When you begin your PR, you'll be asked to provide the following:
@@ -150,29 +150,29 @@ When you begin your PR, you'll be asked to provide the following:
150150

151151
* Update the documentation (in `docs/`) to describe the new or changed functionality.
152152

153-
* Update `CHANGELOG.md` (only for user relevant changes). We use `Keep A Changelog <https://keepachangelog.com/en/1.0.0/>`_
153+
* Update ``CHANGELOG.md`` (only for user relevant changes). We use `Keep A Changelog <https://keepachangelog.com/en/1.0.0/>`_
154154
format which categorizes the changes as:
155155

156-
* `Added` for new features.
156+
* ``Added`` for new features.
157157

158-
* `Changed` for changes in existing functionality.
158+
* ``Changed`` for changes in existing functionality.
159159

160-
* `Deprecated` for soon-to-be removed features.
160+
* ``Deprecated`` for soon-to-be removed features.
161161

162-
* `Removed` for now removed features.
162+
* ``Removed`` for now removed features.
163163

164-
* `Fixed` for any bug fixes.
164+
* ``Fixed`` for any bug fixes.
165165

166-
* `Security` in case of vulnerabilities. (Please report any security issues to the
167-
JazzBand security team `<[email protected]>`. Do not file an issue on the tracker
166+
* ``Security`` in case of vulnerabilities. (Please report any security issues to the
167+
JazzBand security team ``<[email protected]>``. Do not file an issue on the tracker
168168
or submit a PR until directed to do so.)
169169

170-
* Make sure your name is in `AUTHORS`. We want to give credit to all contributors!
170+
* Make sure your name is in :file:`AUTHORS`. We want to give credit to all contributors!
171171

172172
If your PR is not yet ready to be merged mark it as a Work-in-Progress
173-
By prepending `WIP:` to the PR title so that it doesn't get inadvertently approved and merged.
173+
By prepending ``WIP:`` to the PR title so that it doesn't get inadvertently approved and merged.
174174

175-
Make sure to request a review by assigning Reviewer `jazzband/django-oauth-toolkit`.
175+
Make sure to request a review by assigning Reviewer ``jazzband/django-oauth-toolkit``.
176176
This will assign the review to the project team and a member will review it. In the meantime you can continue to add
177177
commits to your topic branch (and push them up to GitHub) either if you see something that needs changing, or in
178178
response to a reviewer's comments. If a reviewer asks for changes, you do not need to close the pull and reissue it
@@ -194,7 +194,7 @@ Then merge the changes that you fetched::
194194

195195
git merge upstream/master
196196

197-
For more info, see http://help.github.com/fork-a-repo/
197+
For more information, see the `GitHub Docs on forking the repository <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo>`_.
198198

199199
.. note:: Please be sure to rebase your commits on the master when possible, so your commits can be fast-forwarded: we
200200
try to avoid *merge commits* when they are not necessary.
@@ -209,7 +209,7 @@ The Checklist
209209

210210
A checklist template is automatically added to your PR when you create it. Make sure you've done all the
211211
applicable steps and check them off to indicate you have done so. This is
212-
what you'll see when creating your PR:
212+
what you'll see when creating your PR::
213213

214214
Fixes #
215215

@@ -251,7 +251,7 @@ You can check your coverage locally with the `coverage <https://pypi.org/project
251251
pip install coverage
252252
coverage html -d mycoverage
253253

254-
Open mycoverage/index.html in your browser and you can see a coverage summary and coverage details for each file.
254+
Open :file:`mycoverage/index.html` in your browser and you can see a coverage summary and coverage details for each file.
255255

256256
There's no need to wait for Codecov to complain after you submit your PR.
257257

@@ -263,8 +263,9 @@ Try reading our code and grasp the overall philosophy regarding method and varia
263263
the sake of readability, keep in mind that *simple is better than complex*. If you feel the code is not straightforward,
264264
add a comment. If you think a function is not trivial, add a docstrings.
265265

266-
To see if your code formatting will pass muster use: `tox -e flake8`
266+
To see if your code formatting will pass muster use::
267267

268+
tox -e flake8
268269

269270
The contents of this page are heavily based on the docs from `django-admin2 <https://github.com/twoscoops/django-admin2>`_
270271

@@ -301,14 +302,14 @@ and rtfd.io. This checklist is a reminder of the required steps.
301302
to make them meaningful to users.
302303
- Make a final PR for the release that updates:
303304

304-
- CHANGELOG to show the release date.
305-
- `oauth2_provider/__init__.py` to set `__version__ = "..."`
305+
- :file:`CHANGELOG.md` to show the release date.
306+
- :file:`oauth2_provider/__init__.py` to set ``__version__ = "..."``
306307

307308
- Once the final PR is merged, create and push a tag for the release. You'll shortly
308309
get a notification from Jazzband of the availability of two pypi packages (source tgz
309310
and wheel). Download these locally before releasing them.
310-
- Do a `tox -e build` and extract the downloaded and bullt wheel zip and tgz files into
311-
temp directories and do a `diff -r` to make sure they have the same content.
311+
- Do a ``tox -e build`` and extract the downloaded and built wheel zip and tgz files into
312+
temp directories and do a ``diff -r`` to make sure they have the same content.
312313
(Unfortunately the checksums do not match due to timestamps in the metadata
313314
so you need to compare all the files.)
314315
- Once happy that the above comparison checks out, approve the releases to Pypi.org.

docs/getting_started.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Create a Django project::
4242

4343
django-admin startproject iam
4444

45-
This will create a mysite directory in your current directory. With the following estructure::
45+
This will create a mysite directory in your current directory. With the following structure::
4646

4747
.
4848
└── iam
@@ -109,7 +109,7 @@ Configure ``users.User`` to be the model used for the ``auth`` application by ad
109109

110110
.. code-block:: python
111111
112-
AUTH_USER_MODEL='users.User'
112+
AUTH_USER_MODEL = 'users.User'
113113
114114
Create inital migration for ``users`` application ``User`` model::
115115

@@ -203,7 +203,7 @@ Last change, add ``LOGIN_URL`` to :file:`iam/settings.py`:
203203

204204
.. code-block:: python
205205
206-
LOGIN_URL='/admin/login/'
206+
LOGIN_URL = '/admin/login/'
207207
208208
We will use Django Admin login to make our life easy.
209209

@@ -332,7 +332,7 @@ To be more easy to visualize::
332332

333333
The OAuth2 provider will return the follow response:
334334

335-
.. code-block:: javascript
335+
.. code-block:: json
336336
337337
{
338338
"access_token": "jooqrnOrNa0BrNWlg68u9sl6SkdFZg",
@@ -402,7 +402,7 @@ To be easier to visualize::
402402

403403
The OAuth2 provider will return the following response:
404404

405-
.. code-block:: javascript
405+
.. code-block:: json
406406
407407
{
408408
"access_token": "PaZDOD5UwzbGOFsQr34LQ7JUYOj3yK",

docs/install.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Installation
22
============
33

4-
Install with pip
5-
::
4+
Install with pip::
5+
66
pip install django-oauth-toolkit
77

8-
Add `oauth2_provider` to your `INSTALLED_APPS`
8+
Add ``oauth2_provider`` to your ``INSTALLED_APPS``
99

1010
.. code-block:: python
1111
@@ -15,7 +15,7 @@ Add `oauth2_provider` to your `INSTALLED_APPS`
1515
)
1616
1717
18-
If you need an OAuth2 provider you'll want to add the following to your urls.py
18+
If you need an OAuth2 provider you'll want to add the following to your :file:`urls.py`
1919

2020
.. code-block:: python
2121
@@ -26,15 +26,14 @@ If you need an OAuth2 provider you'll want to add the following to your urls.py
2626
path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
2727
]
2828
29-
Or using `re_path()`
29+
Or using ``re_path()``
3030

3131
.. code-block:: python
3232
3333
from django.urls import include, re_path
3434
3535
urlpatterns = [
3636
...
37-
3837
re_path(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')),
3938
]
4039
@@ -43,7 +42,7 @@ Sync your database
4342

4443
.. sourcecode:: sh
4544

46-
$ python manage.py migrate oauth2_provider
45+
python manage.py migrate oauth2_provider
4746

4847
Next step is :doc:`getting started <getting_started>` or :doc:`first tutorial <tutorial/tutorial_01>`.
4948

docs/management_commands.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,5 @@ The ``createapplication`` management command provides a shortcut to create a new
9292
--force-color Force colorization of the command output.
9393
--skip-checks Skip system checks.
9494
95-
If you let `createapplication` auto-generate the secret then it displays the value before hashing it.
95+
If you let ``createapplication`` auto-generate the secret then it displays the value before hashing it.
9696

0 commit comments

Comments
 (0)