searchdocs¶
Search the Python documentation from your terminal.
Built on top of sphobjinv,
which can be used for more advanced manipulation and searching of Sphinx objects.inv
files.
Installation¶
python3 -m pip install searchdocs --user
python3 -m pip install git+https://github.com/domdfcoding/searchdocs@master --user
Contents¶
Usage¶
searchdocs¶
Search for SEARCH_TERM
in the Python documentation, and print the URL of the best match.
searchdocs [OPTIONS] SEARCH_TERM
Options
-
--browser
¶
Open the documentation in the default web browser.
Arguments
-
SEARCH_TERM
¶
Required argument.
Tip
The output from the searchdocs
command can be piped into the lynx(1) command
to open a web browser in the terminal:
searchdocs rmtree | lynx -
Public API¶
Search the Python documentation from your terminal.
Data:
Directory in which cached files are stored. |
Functions:
|
Returns the path to the cache subdirectory for the given URL. |
|
Download the Sphinx |
|
Find the complete documentation URL for the given function, class, method etc. |
|
Resolve any redirects in the given URL. |
-
cache_dir
= PosixPathPlus('/home/docs/.cache/searchdocs')¶ Type:
PosixPathPlus
Directory in which cached files are stored.
-
download_objects_inv
(docs_url)[source]¶ Download the Sphinx
objects.inv
file for the documentation available at the given URL.- Parameters
docs_url (
Union
[str
,RequestsURL
]) – The base URL for the documentation, e.g."https://docs.python.org/3/"
.- Return type
- Returns
The filename of the cached file.
-
find_url
(docs_url, search_term)[source]¶ Find the complete documentation URL for the given function, class, method etc.
- Parameters
docs_url (
Union
[str
,RequestsURL
]) – The base URL for the documentation, e.g."https://docs.python.org/3/"
.search_term (
str
) – The object to search for, e.g.'TemporaryDirectory'
.
- Return type
- Returns
The url of the object in the documentation, e.g.
URL('https://docs.python.org/3/'library/tempfile.html#tempfile.TemporaryDirectory')
.
-
resolve_url
(url)[source]¶ Resolve any redirects in the given URL.
- Parameters
url (
Union
[str
,RequestsURL
])- Return type
Contributing¶
searchdocs
uses tox to automate testing and packaging,
and pre-commit to maintain code quality.
Install pre-commit
with pip
and install the git hook:
python -m pip install pre-commit
pre-commit install
Coding style¶
formate is used for code formatting.
It can be run manually via pre-commit
:
pre-commit run formate -a
Or, to run the complete autoformatting suite:
pre-commit run -a
Automated tests¶
Tests are run with tox
and pytest
.
To run tests for a specific Python version, such as Python 3.6:
tox -e py36
To run tests for all Python versions, simply run:
tox
Build documentation locally¶
The documentation is powered by Sphinx. A local copy of the documentation can be built with tox
:
tox -e docs
Downloading source code¶
The searchdocs
source code is available on GitHub,
and can be accessed from the following URL: https://github.com/domdfcoding/searchdocs
If you have git
installed, you can clone the repository with the following command:
git clone https://github.com/domdfcoding/searchdocs
Cloning into 'searchdocs'...
remote: Enumerating objects: 47, done.
remote: Counting objects: 100% (47/47), done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 173 (delta 16), reused 17 (delta 6), pack-reused 126
Receiving objects: 100% (173/173), 126.56 KiB | 678.00 KiB/s, done.
Resolving deltas: 100% (66/66), done.

Downloading a ‘zip’ file of the source code¶
Building from source¶
The recommended way to build searchdocs
is to use tox:
tox -e build
The source and wheel distributions will be in the directory dist
.
If you wish, you may also use pep517.build or another PEP 517-compatible build tool.
License¶
searchdocs
is licensed under the MIT License
A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.
Permissions | Conditions | Limitations |
---|---|---|
|
|
Copyright (c) 2021 Dominic Davis-Foster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
View the Function Index or browse the Source Code.