-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation is hosted on readthedocs.org, it’s free for public open-source project and a popular choice. The Sphinx readthedocs theme was picked for the same reasons. The code examples are verified with doctest. Most documentation for the fields live in the code directly, in an attempt to keep them in sync.
- Loading branch information
1 parent
ecf086c
commit 9d568cc
Showing
17 changed files
with
631 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ jobs: | |
matrix: | ||
tox-environment: | ||
- black | ||
- doctest | ||
- flake8 | ||
- isort | ||
env: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details | ||
version: 2 | ||
|
||
python: | ||
install: | ||
- requirements: docs/requirements.txt | ||
- method: pip | ||
path: . | ||
|
||
sphinx: | ||
fail_on_warning: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
BUILDDIR = _build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# For the full list of built-in configuration values, see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
import os | ||
import pathlib | ||
import sys | ||
|
||
current_dir = pathlib.Path(__file__).parent | ||
# Find current settings module for doctests. | ||
sys.path.insert(0, str(current_dir)) | ||
sys.path.insert(0, str(current_dir / "ext")) | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") | ||
|
||
# -- Project information ----------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information | ||
|
||
project = "django-phonenumber-field" | ||
copyright = "2022, django-phonenumber-field" | ||
author = "Stefan Foulis" | ||
|
||
# -- General configuration --------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration | ||
|
||
extensions = [ | ||
"sphinx.ext.autodoc", | ||
"sphinx.ext.doctest", | ||
"sphinx.ext.intersphinx", | ||
"phonenumber_field_docs", | ||
] | ||
|
||
templates_path = ["_templates"] | ||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] | ||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output | ||
|
||
html_theme = "sphinx_rtd_theme" | ||
html_static_path = [] | ||
|
||
# -- Options for extensions -------------------------------------------------- | ||
|
||
intersphinx_mapping = { | ||
"django": ( | ||
"https://docs.djangoproject.com/en/dev/", | ||
"https://docs.djangoproject.com/en/dev/_objects/", | ||
), | ||
"python": ("https://docs.python.org/3/", None), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def setup(app): | ||
app.add_crossref_type( | ||
directivename="setting", rolename="setting", indextemplate="pair: %s; setting" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
🕿 django-phonenumber-field 🕿 | ||
============================= | ||
|
||
A `Django <https://www.djangoproject.com/>`_ library which interfaces with | ||
`python-phonenumbers <https://github.com/daviddrysdale/python-phonenumbers>`_ | ||
to validate, pretty print and convert phone numbers. The python-phonenumbers | ||
library is a port of Google’s `libphonenumber | ||
<https://github.com/google/libphonenumber>`_ library, which powers Android’s | ||
phone number handling. | ||
|
||
Installation | ||
============ | ||
|
||
Choosing a phonenumbers provider | ||
-------------------------------- | ||
|
||
The `python-phonenumbers <https://github.com/daviddrysdale/python-phonenumbers>`_ library comes in `two flavors | ||
<https://github.com/daviddrysdale/python-phonenumbers#memory-usage>`_: | ||
|
||
.. code-block:: | ||
# Installs phonenumbers minimal metadata | ||
pip install "django-phonenumber-field[phonenumberslite]" | ||
.. code-block:: | ||
# Installs phonenumbers extended features (e.g. geocoding) | ||
pip install "django-phonenumber-field[phonenumbers]" | ||
Setup | ||
----- | ||
|
||
Add ``phonenumber_field`` to the list of the installed apps in | ||
your ``settings.py`` file :external+django:setting:`INSTALLED_APPS`: | ||
|
||
.. code-block:: python | ||
INSTALLED_APPS = [ | ||
# Other apps… | ||
"phonenumber_field", | ||
] | ||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
reference |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=. | ||
set BUILDDIR=_build | ||
|
||
%SPHINXBUILD% >NUL 2>NUL | ||
if errorlevel 9009 ( | ||
echo. | ||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
echo.installed, then set the SPHINXBUILD environment variable to point | ||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
echo.may add the Sphinx directory to PATH. | ||
echo. | ||
echo.If you don't have Sphinx installed, grab it from | ||
echo.https://www.sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
if "%1" == "" goto help | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
Oops, something went wrong.