Skip to content

Commit d5ab5ff

Browse files
authored
Cleaned up Py doc sphinx warnings/errors and added README (#14191)
- Cleaned up various sphinx build error and warnings - Added py/docs/README.rst leaving some instructions for the next person
1 parent 7540e09 commit d5ab5ff

File tree

4 files changed

+84
-12
lines changed

4 files changed

+84
-12
lines changed

py/docs/README.rst

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
==========================
2+
About Python Documentation
3+
==========================
4+
5+
This directory, ``py/docs``, is the source for the API Reference Documentation
6+
and basic Python documentation as well as the main README for the GitHub and
7+
PyPI package.
8+
9+
10+
How to build docs
11+
=================
12+
13+
One can build the Python documentation without doing a full bazel build. The
14+
following instructions will build the setup a virtual environment and installs tox, clones the
15+
selenium repo and then runs ``tox -c py/tox.ini`` building the Python documentation.
16+
17+
.. code-block:: console
18+
19+
virtualenv test-py38-env
20+
source test-py38-env/bin/activate
21+
pip install tox
22+
git clone [email protected]:SeleniumHQ/selenium.git
23+
cd selenium/
24+
# uncomment and switch to your development branch if needed
25+
#git switch -c feature-branch origin/feature-branch
26+
tox -c py/tox.ini
27+
28+
Works in similar manner as the larger selenium bazel doing just the python documentation portion.
29+
30+
What is happening under the covers of tox, sphinx
31+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32+
tox is essentially a build tool for Python. Here it setups its own virtualenv and installs the
33+
documentation packages (sphinx and jinja2) as well as the required selenium python
34+
dependencies. Then tox runs the sphinx generate autodoc stub files and then builds the docs.
35+
36+
Sphinx is .. well a much larger topic then what we could cover here. Most important to say
37+
here is that the docs are using the "classic" theme and than the majority of the api documentation
38+
is autogenerated. There is plenty of information available and currently the documentation is
39+
fairly small and not complex. So some basic understanding of restructed text and the Sphinx tool chain
40+
should be sufficient to contribute and develop the Python docs.
41+
42+
To clean up the build / tox cache
43+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44+
Although there is a Sphinx Makefile option to clean up using the tox environment above one can
45+
manually clean the build by deleting the build directory on the root (selenium/build using the
46+
default directory on git clone). Noting that both Sphinx and tox cache parts of their build and
47+
recognize changes to speed up their respective builds. But at times one wants to start fresh
48+
deleting the aformentioned directory will clean the Sphinx cache or removing selenium/py/.tox
49+
directory for cleaning the tox environment.
50+
51+
52+
Known documentation issues
53+
==========================
54+
The API Reference primarily builds from the source code. But currently the initial template stating
55+
which modules to document is hard coded within py/docs/source/api.rst. So if modules are added or
56+
removed then the generated docs will be inaccurate. It would be preferred that the API docs generate
57+
soley from the code if possible. This is being tracked in `#14178 <https://github.com/SeleniumHQ/selenium/issues/14178>`_
58+
59+
We are working through the Sphinx build Warnings and Errors trying to clean up botht the syntax and
60+
the build.
61+
62+
Contributing to Python docs
63+
===========================
64+
First it is recommended that you read the main `CONTRIBUTING.md <https://github.com/SeleniumHQ/selenium/blob/trunk/CONTRIBUTING.md>`_.
65+
66+
Some steps for contibuting to the Python documentation ..
67+
68+
- Check out changes locally using instruction above.
69+
- Try to resolve any warnings/issues.
70+
- If too arduous either ask for help or add to list of known issue.
71+
- If this process is updated please update this doc as well to help the next person.

py/selenium/webdriver/chromium/webdriver.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ def launch_app(self, id):
7777
def get_network_conditions(self):
7878
"""Gets Chromium network emulation settings.
7979
80-
:Returns: A dict. For example: {'latency': 4,
81-
'download_throughput': 2, 'upload_throughput': 2, 'offline':
82-
False}
80+
:Returns:
81+
A dict.
82+
For example: {'latency': 4, 'download_throughput': 2, 'upload_throughput': 2, 'offline': False}
8383
"""
8484
return self.execute("getNetworkConditions")["value"]
8585

py/selenium/webdriver/common/virtual_authenticator.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ def __init__(
9191
9292
:Args:
9393
- credential_id (bytes): Unique base64 encoded string.
94-
is_resident_credential (bool): Whether the credential is client-side discoverable.
95-
rp_id (str): Relying party identifier.
96-
user_handle (bytes): userHandle associated to the credential. Must be Base64 encoded string. Can be None.
97-
private_key (bytes): Base64 encoded PKCS#8 private key.
98-
sign_count (int): intital value for a signature counter.
94+
- is_resident_credential (bool): Whether the credential is client-side discoverable.
95+
- rp_id (str): Relying party identifier.
96+
- user_handle (bytes): userHandle associated to the credential. Must be Base64 encoded string. Can be None.
97+
- private_key (bytes): Base64 encoded PKCS#8 private key.
98+
- sign_count (int): intital value for a signature counter.
9999
"""
100100
self._id = credential_id
101101
self._is_resident_credential = is_resident_credential

py/selenium/webdriver/support/relative_locator.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ def with_tag_name(tag_name: str) -> "RelativeBy":
3232
3333
Note: This method may be removed in future versions, please use
3434
`locate_with` instead.
35+
3536
:Args:
3637
- tag_name: the DOM tag of element to start searching.
3738
:Returns:
38-
- RelativeBy - use this object to create filters within a
39-
`find_elements` call.
39+
- RelativeBy: use this object to create filters within a
40+
`find_elements` call.
4041
"""
4142
if not tag_name:
4243
raise WebDriverException("tag_name can not be null")
@@ -50,8 +51,8 @@ def locate_with(by: ByType, using: str) -> "RelativeBy":
5051
- by: The value from `By` passed in.
5152
- using: search term to find the element with.
5253
:Returns:
53-
- RelativeBy - use this object to create filters within a
54-
`find_elements` call.
54+
- RelativeBy: use this object to create filters within a
55+
`find_elements` call.
5556
"""
5657
assert by is not None, "Please pass in a by argument"
5758
assert using is not None, "Please pass in a using argument"

0 commit comments

Comments
 (0)