diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e01fd366..fc7efab2b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 }}' diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 000000000..e71d34f3a --- /dev/null +++ b/.readthedocs.yml @@ -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: . diff --git a/docs/custom_language_detection.rst b/docs/custom_language_detection.rst index f05c0176b..c20d829c9 100644 --- a/docs/custom_language_detection.rst +++ b/docs/custom_language_detection.rst @@ -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 `_ +`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 `_ and `langdetect `_, and allows you to implement your own custom language detection. .. warning:: @@ -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 `_ models. +Find more information about `fasttext `__ models. You can download your model of choice using ``dateparser-download``. Downloading small model:: @@ -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 @@ -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 diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..c625976ab --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +sphinx==7.2.6 +sphinx-rtd-theme==1.3.0 diff --git a/docs/settings.rst b/docs/settings.rst index 72d9103f9..18bc0a598 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -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 +++++++++++++++++++++++++++ @@ -193,7 +193,7 @@ The following parsers exist: followed by additional digits or a period (``.``), those first 10 digits are interpreted as `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 diff --git a/tox.ini b/tox.ini index 1f515e521..e62b86828 100644 --- a/tox.ini +++ b/tox.ini @@ -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