-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
267 additions
and
0 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 |
---|---|---|
|
@@ -8,3 +8,5 @@ dist/ | |
tmp/ | ||
regexes.yaml | ||
_regexes.py | ||
# sphinx build dir | ||
_build/ |
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,49 @@ | ||
Changelog | ||
--------- | ||
|
||
This repository is mostly a wrapper for the `User Agent String Parser | ||
<https://github.com/ua-parser/uap-core>`_ data. | ||
|
||
As such, "data" changes should be lookled up in `the main project's | ||
releases <https://github.com/ua-parser/uap-core/tags>`_, at least | ||
assuming this is synchronised. | ||
|
||
API-level changes are documented below: | ||
|
||
1.0 (pending) | ||
~~~~~~~~~~~~~ | ||
|
||
First truly major change in a long time. I still have no idea what | ||
versioning scheme to use though. | ||
|
||
- Dropped compatibility with CPython 2.7, CPython 3.6, and CPython | ||
3.7, this includes the legacy API. | ||
- A brand new fully typed API following PEP8 conventions has been | ||
added, the surface follows the logic of the old one (because it's | ||
simple and it works) but it returns proper instances (rather than | ||
undifferentiated dicts) and should allow for the development of | ||
faster opt-in parsers with less fear of breaking existing use-cases. | ||
|
||
Notably, the new API also makes initialising parsers from custom | ||
yaml files rather more practical than having to set an environment | ||
variable. | ||
|
||
Consider migrating. | ||
- The new API switches over from the google-style to the sphinx-style | ||
docstring format as hopefully we'll publish something on RTD | ||
eventually. | ||
- The legacy parsing API (``ua_parser.user_agent_parser``) is | ||
recommended against but not deprecated yet, although the ``Parse*`` | ||
functions are pending deprecation, and: | ||
|
||
- ``PrettyUserAgent`` and ``PrettyOS`` are tentatively deprecated as | ||
it's not clear what their use-case is, but they could be | ||
un-deprecated. | ||
- Any use of the ``jsParseBits`` (js overrides in the ``Parse*`` | ||
functions) is deprecated. | ||
- ``GetFilters`` is deprecated. | ||
- ``ParseWithJSOverrides`` and ``Pretty`` are formally deprecated | ||
(they were never not deprecated). | ||
- The ``MatchSpans`` methods of the ``*Parser`` objects has been | ||
removed, they're undocumented, not used internally, and don't have | ||
a clear purpose. |
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,27 @@ | ||
API | ||
=== | ||
|
||
Main Helpers | ||
------------ | ||
|
||
.. automodule:: ua_parser | ||
:members: | ||
|
||
Core Types | ||
---------- | ||
|
||
.. automodule:: ua_parser.types | ||
:members: | ||
|
||
Basic Parser | ||
------------ | ||
|
||
.. automodule:: ua_parser.basic | ||
:members: | ||
|
||
Caches | ||
------ | ||
|
||
.. automodule:: ua_parser.caching | ||
:members: | ||
|
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 @@ | ||
../changelog.rst |
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 @@ | ||
# 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 | ||
# -- Project information ----------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information | ||
|
||
project = "ua-parser" | ||
copyright = "2023, ua-parser team" | ||
author = "ua-parser team" | ||
|
||
version = "1.0.0a2" | ||
release = "1.0.0a2" | ||
|
||
# -- General configuration --------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration | ||
|
||
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.intersphinx"] | ||
|
||
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 = "alabaster" | ||
html_static_path = ["_static"] | ||
|
||
intersphinx_mapping = { | ||
"python": ("https://docs.python.org/3", None), | ||
} | ||
|
||
autodoc_member_order = "bysource" | ||
autodoc_default_flags = ["members", "special-members"] |
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,44 @@ | ||
.. highlight:: sh | ||
|
||
Development | ||
=========== | ||
|
||
Prerequisites | ||
------------- | ||
|
||
- git | ||
- tox_, not entirely required but probably a good idea in order to run | ||
tests and maintenance tasks locally | ||
- optionally something like pyenv_ in order to install multiple | ||
version of Python and run tests with all of them, see | ||
:download:`../tox.ini` for the currently supported list | ||
|
||
Setup | ||
----- | ||
|
||
Clone the project from github:: | ||
|
||
$ git clone --recurse-submodule https://github.com/ua-parser/uap-python | ||
|
||
The project mostly uses tox_ to run tests and maintenance task, `tox | ||
exec`_ can be used to open shells in the environments for interactive | ||
testing. | ||
|
||
However it's also possible to install from the local copy, either via | ||
an editable install:: | ||
|
||
$ pip install -e . | ||
|
||
which allows editing the code and having it reflect immediately in the | ||
installation (code generation excluded), or a regular install:: | ||
|
||
$ pip install . | ||
|
||
which requires re-installing after each change. | ||
|
||
Tox | ||
--- | ||
|
||
.. _pyenv: https://github.com/pyenv/pyenv | ||
.. _tox: https://tox.wiki/en/latest/index.html | ||
.. _tox exec: https://tox.wiki/en/latest/cli_interface.html#tox-exec-(e) |
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,24 @@ | ||
.. ua-parser documentation master file, created by | ||
sphinx-quickstart on Sun Jul 2 21:43:06 2023. | ||
You can adapt this file completely to your liking, but it should at least | ||
contain the root `toctree` directive. | ||
Welcome to ua-parser's documentation! | ||
===================================== | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:caption: Contents: | ||
|
||
quickstart <quickstart> | ||
api | ||
migrating | ||
changelog | ||
development | ||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
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 |
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,22 @@ | ||
Migrating from 0.x | ||
================== | ||
|
||
While migrating is not quite necessary as the legacy API is not | ||
getting removed just yet, it's also pretty simple: | ||
|
||
- Remove one level of API, while the utility functions of the legacy | ||
API live in ``ua_parser.user_agent_parser`` the new API lives in | ||
``ua_parser`` at the root of the package. | ||
- Convert the function names from ``PascalCase`` to ``snake_case``. | ||
- Wrap the calls in ``dataclasses.asdict``: the functions now return | ||
proper types, but these types are directly compatible with the old | ||
results. | ||
|
||
Alternatively, convert the caller code to leveraging the new typed | ||
API, items become attributes, and optional attributes are `Optional | ||
<https://docs.python.org/3/library/typing.html#typing.Optional>`_. | ||
|
||
That should be it. If there are issues with the process, `just ask | ||
<https://github.com/ua-parser/uap-python/discussions/categories/general>`_ | ||
or `open an issue | ||
<https://github.com/ua-parser/uap-python/issues/new>`_. |
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 @@ | ||
../README.rst |
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