Skip to content

Commit

Permalink
Fix the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallaecio committed Nov 17, 2023
1 parent 0c7a9d4 commit c54d7e4
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
- python-version: "3.11"
env:
TOXENV: twinecheck
- python-version: "3.11" # Keep in sync with tox.ini
env:
TOXENV: docs
steps:
- uses: actions/checkout@v3
- name: 'Set up Python ${{ matrix.python-version }}'
Expand Down
17 changes: 17 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
formats: all
sphinx:
configuration: docs/conf.py
fail_on_warning: true

build:
os: ubuntu-20.04
tools:
# For available versions, see:
# https://docs.readthedocs.io/en/stable/config-file/v2.html#build-tools-python
python: "3.11" # Keep in sync with .github/workflows/checks.yml

python:
install:
- requirements: docs/requirements.txt
- path: .
26 changes: 13 additions & 13 deletions docs/custom_language_detection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Custom language detection
=========================

`dateparser` allows to customize the language detection behavior by using the ``detect_languages_function`` parameter.
It currently supports two language detection libraries out of the box: `fastText <https://github.com/facebookresearch/fastText>`_
`dateparser` allows to customize the language detection behavior by using the ``detect_languages_function`` parameter.
It currently supports two language detection libraries out of the box: `fastText <https://github.com/facebookresearch/fastText>`_
and `langdetect <https://github.com/Mimino666/langdetect>`_, and allows you to implement your own custom language detection.

.. warning::
Expand All @@ -25,7 +25,7 @@ parameter. Example::
>>> dateparser.parse('12/12/12', detect_languages_function=detect_languages)

The fastText integration currently supports the large and the small models.
Find more information about `fasttext <https://fasttext.cc/blog/2017/10/02/blog-post.html>`_ models.
Find more information about `fasttext <https://fasttext.cc/blog/2017/10/02/blog-post.html>`__ models.
You can download your model of choice using ``dateparser-download``.

Downloading small model::
Expand All @@ -42,7 +42,7 @@ Deleting all cached models::

.. note::

If no model has been downloaded, the fastText wrapper downloads and uses
If no model has been downloaded, the fastText wrapper downloads and uses
the small model by default.

langdetect
Expand Down Expand Up @@ -75,20 +75,20 @@ Wrapper for boilerplate for implementing custom language detections::
"""
Takes 2 parameters, `text` and `confidence_threshold`, and returns
a list of `languages codes`.

* `text` is the input string whose language needs to be detected.
* `confidence_threshold` is a number between 0 and 1 that indicates the

* `confidence_threshold` is a number between 0 and 1 that indicates the
minimum confidence required for language matches.
For language detection libraries that, for each language, indicate how
confident they are that the language matches the input text, you should

For language detection libraries that, for each language, indicate how
confident they are that the language matches the input text, you should
filter out languages with a confidence lower than this value (adjusted,
if needed, to the confidence range of the target library).
This value comes from the dateparser setting

This value comes from the dateparser setting
`LANGUAGE_DETECTION_CONFIDENCE_THRESHOLD`.

The result must be a list of languages codes (strings).
"""
# here you can apply your own logic
Expand Down
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinx==7.2.6
sphinx-rtd-theme==1.3.0
4 changes: 2 additions & 2 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ languages for parsing when language detection fails. eg. ["en", "fr"]:
>>> from dateparser import parse
>>> parse('3 de marzo de 2020', settings={'DEFAULT_LANGUAGES': ["es"]})

.. note:: When using this setting, these languages will be tried after trying with the detected languages with no success. It is especially useful when using the ``detect_languages_function`.
.. note:: When using this setting, these languages will be tried after trying with the detected languages with no success. It is especially useful when using ``detect_languages_function``.

Optional language detection
+++++++++++++++++++++++++++
Expand Down Expand Up @@ -193,7 +193,7 @@ The following parsers exist:
followed by additional digits or a period (``.``), those first 10 digits
are interpreted as `Unix time <https://en.wikipedia.org/wiki/Unix_time>`_.

- ``'negative-timestamp'``: ``'timestamp'`` for negative timestamps. For
- ``'negative-timestamp'``: ``'timestamp'`` for negative timestamps. For
example, parses ``-186454800000`` as ``1964-02-03T23:00:00``.

- ``'relative-time'``: Parses dates and times expressed in relation to the
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ commands =

[testenv:docs]
changedir = docs
extras = []
deps =
{[testenv]deps}
sphinx
sphinx-rtd-theme
-rdocs/requirements.txt
commands =
sphinx-build -b html . {envtmpdir}/html
sphinx-build -W -b html . {envtmpdir}/html

[testenv:twinecheck]
basepython = python3
Expand Down

0 comments on commit c54d7e4

Please sign in to comment.