Skip to content

Commit 923cef4

Browse files
authored
Merge pull request jxmorris12#125 from mdevolde/auto_doc
docs: added auto-genereted doc (sphinx), corrected the way of writing class attributes, edited optional dependencies (from opt to groups)
2 parents b38e2b5 + 8d5fc51 commit 923cef4

File tree

16 files changed

+361
-109
lines changed

16 files changed

+361
-109
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Current LanguageTool version: **6.8-SNAPSHOT**
1010

11-
This is a Python wrapper for [LanguageTool](https://languagetool.org). LanguageTool is open-source grammar tool, also known as the spellchecker for OpenOffice. This library allows you to make to detect grammar errors and spelling mistakes through a Python script or through a command-line interface.
11+
This is a Python wrapper for [LanguageTool](https://languagetool.org). LanguageTool is an open-source grammar tool, also known as the spellchecker for OpenOffice. This library allows you to detect grammar errors and spelling mistakes through a Python script or through a command-line interface.
1212

1313
## Local and Remote Servers
1414

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/conf.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8+
9+
project = "language_tool_python"
10+
copyright = "2025, jxmorris12"
11+
author = "jxmorris12"
12+
release = "2.9.5" # Keep in sync with pyproject.toml
13+
14+
# -- General configuration ---------------------------------------------------
15+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
16+
17+
extensions = ["sphinx.ext.autodoc", "sphinx_design"]
18+
19+
templates_path = ["_templates"]
20+
exclude_patterns = []
21+
22+
23+
# -- Options for HTML output -------------------------------------------------
24+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
25+
26+
html_theme = "furo"
27+
html_static_path = ["_static"]
28+
29+
# -- Options for autodoc -----------------------------------------------------
30+
31+
autodoc_default_options = {
32+
"members": True,
33+
"undoc-members": True,
34+
"private-members": True,
35+
"show-inheritance": True,
36+
}

docs/source/index.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.. language_tool_python documentation master file, created by
2+
sphinx-quickstart on Wed Nov 12 18:23:43 2025.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
language_tool_python documentation
7+
==================================
8+
9+
`language_tool_python` is a Python wrapper for `LanguageTool <https://languagetool.org>`_. LanguageTool is an open-source grammar tool, also known as the spellchecker for OpenOffice. This library allows you to detect grammar errors and spelling mistakes through a Python script or through a command-line interface.
10+
11+
In this documentation
12+
---------------------
13+
14+
* :doc:`References <./references/language_tool_python>`
15+
* :doc:`Modules <./references/modules>`
16+
17+
18+
.. toctree::
19+
:maxdepth: 2
20+
:caption: Contents:
21+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
language\_tool\_python package
2+
==============================
3+
4+
Submodules
5+
----------
6+
7+
language\_tool\_python.config\_file module
8+
------------------------------------------
9+
10+
.. automodule:: language_tool_python.config_file
11+
:members:
12+
:show-inheritance:
13+
:undoc-members:
14+
15+
language\_tool\_python.download\_lt module
16+
------------------------------------------
17+
18+
.. automodule:: language_tool_python.download_lt
19+
:members:
20+
:show-inheritance:
21+
:undoc-members:
22+
23+
language\_tool\_python.exceptions module
24+
----------------------------------------
25+
26+
.. automodule:: language_tool_python.exceptions
27+
:members:
28+
:show-inheritance:
29+
:undoc-members:
30+
31+
language\_tool\_python.language\_tag module
32+
-------------------------------------------
33+
34+
.. automodule:: language_tool_python.language_tag
35+
:members:
36+
:show-inheritance:
37+
:undoc-members:
38+
39+
language\_tool\_python.match module
40+
-----------------------------------
41+
42+
.. automodule:: language_tool_python.match
43+
:members:
44+
:show-inheritance:
45+
:undoc-members:
46+
47+
language\_tool\_python.server module
48+
------------------------------------
49+
50+
.. automodule:: language_tool_python.server
51+
:members:
52+
:show-inheritance:
53+
:undoc-members:
54+
55+
language\_tool\_python.utils module
56+
-----------------------------------
57+
58+
.. automodule:: language_tool_python.utils
59+
:members:
60+
:show-inheritance:
61+
:undoc-members:
62+
63+
Module contents
64+
---------------
65+
66+
.. automodule:: language_tool_python
67+
:members:
68+
:show-inheritance:
69+
:undoc-members:

docs/source/references/modules.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language_tool_python
2+
====================
3+
4+
.. toctree::
5+
:maxdepth: 4
6+
7+
language_tool_python

language_tool_python/__main__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ class RulesAction(argparse.Action):
121121
namespace when the action is triggered. It updates the attribute specified
122122
by 'self.dest' with the provided values.
123123
124-
Attributes:
125-
dest (str): the destination attribute to update
124+
.. attribute:: dest
125+
:type: str
126+
The destination attribute to update.
126127
"""
127128

128129
def __call__(

language_tool_python/config_file.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@ class OptionSpec:
1818
This class defines the structure and behavior of a configuration option,
1919
including its type constraints, encoding mechanism, and optional validation.
2020
21-
Attributes:
22-
py_types (Union[type, tuple[type, ...]]): The Python type(s) that this option accepts.
23-
encoder (Callable[[Any], str]): A callable that converts the option value to its string representation.
24-
validator (Optional[Callable[[Any], None]]): An optional callable that validates the option value.
25-
26-
.. note::
2721
This class is frozen (immutable) to ensure configuration specifications
2822
remain constant throughout the application lifecycle.
2923
"""
3024

3125
py_types: Union[type, tuple[type, ...]]
26+
"""The Python type(s) that this option accepts."""
27+
3228
encoder: Callable[[Any], str]
29+
"""A callable that converts the option value to its string representation."""
30+
3331
validator: Optional[Callable[[Any], None]] = None
32+
"""An optional validator function for the option value."""
3433

3534

3635
def _bool_encoder(v: Any) -> str:
@@ -201,14 +200,13 @@ class LanguageToolConfig:
201200
202201
:param config: Dictionary containing configuration keys and values.
203202
:type config: Dict[str, Any]
204-
205-
Attributes:
206-
config (Dict[str, Any]): Dictionary containing configuration keys and values.
207-
path (str): Path to the temporary file storing the configuration.
208203
"""
209204

210205
config: Dict[str, Any]
206+
"""Dictionary containing configuration keys and values."""
207+
211208
path: str
209+
"""Path to the temporary file storing the configuration."""
212210

213211
def __init__(self, config: Dict[str, Any]):
214212
"""

language_tool_python/download_lt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ def confirm_java_compatibility(
117117
)
118118
)
119119

120-
# Some installs of java show the version number like `14.0.1`
121-
# and others show `1.14.0.1`
120+
# Some installs of java show the version number like '14.0.1'
121+
# and others show '1.14.0.1'
122122
# (with a leading 1). We want to support both.
123123
# (See softwareengineering.stackexchange.com/questions/175075/why-is-java-version-1-x-referred-to-as-java-x)
124124
if is_old_version:

0 commit comments

Comments
 (0)