Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation rewrite (Q1 2021) #9474

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5a2de5b
Enable MyST in documentation
pradyunsg Jan 17, 2021
0998b3d
Remove the docs-feedback extension
pradyunsg Jan 17, 2021
ac2c98a
Add new documentation skeleton
pradyunsg Jan 17, 2021
7b1b87c
Drop old .rst files overlapping with new skeleton
pradyunsg Jan 17, 2021
c61ebed
Rewrite docs/conf.py
pradyunsg Jan 17, 2021
4915115
Add configuration for MyST
pradyunsg Jan 17, 2021
54e20ef
Add .md files in docs/ to MANIFEST
pradyunsg Jan 19, 2021
09ee251
Add autodoc and todo plugins for Sphinx
pradyunsg Jan 17, 2021
79614e3
Move CLI docs into cli/ and write new index page
pradyunsg Jan 17, 2021
3c3967c
Change news to Markdown
pradyunsg Jan 17, 2021
3d159ca
Add sphinx-copybutton
pradyunsg Jan 17, 2021
f57c248
Populate the new Getting Started page
pradyunsg Jan 17, 2021
f808256
Point to the PyPUG tutorial from quickstart
pradyunsg Jan 17, 2021
937a74d
Blacken pip_sphinxext.py
pradyunsg Jan 18, 2021
5e6e37e
Add a pip-cli directive for MyST
pradyunsg Jan 18, 2021
e89328d
Enable black on docs/
pradyunsg Jan 18, 2021
0b959be
Add dedicated page for authentication
pradyunsg Jan 18, 2021
26b21ab
Add dedicated page for Caching
pradyunsg Jan 18, 2021
57c166e
Add dedicated page for Configuration
pradyunsg Jan 18, 2021
8094e23
Add dedicated page for editable installs
pradyunsg Jan 18, 2021
e0693a7
Add dedicated page for Repeatable Installs
pradyunsg Jan 18, 2021
de0d794
Add dedicated page for Requirements Files
pradyunsg Jan 18, 2021
e899320
Add dedicated page for User Installs
pradyunsg Jan 18, 2021
001fb46
Add dedicated page for VCS support
pradyunsg Jan 19, 2021
b8fa4b9
Add dedicated page for Requirements File format
pradyunsg Feb 4, 2021
4e400ee
Add a docs-live nox session
pradyunsg Feb 4, 2021
01305a5
Add explanation page for custom install options
pradyunsg Feb 21, 2021
4b0712e
Capitalise all headings
pradyunsg Feb 21, 2021
96cbeaf
Add dedicated page on how configuration works
pradyunsg Feb 28, 2021
a339fb1
:newspaper:
pradyunsg Feb 28, 2021
7c3af23
Tweak sentence in authentication explainer
pradyunsg Mar 3, 2021
8b4d927
Move compatibility information to getting-started
pradyunsg Mar 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ repos:
- id: black
exclude: |
(?x)
^docs/|
^src/pip/_internal/commands|
^src/pip/_internal/index|
^src/pip/_internal/models|
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exclude noxfile.py

recursive-include src/pip/_vendor *.pem
recursive-include src/pip/_vendor py.typed
recursive-include docs *.css *.rst *.py
recursive-include docs *.css *.py *.rst *.md

exclude src/pip/_vendor/six
exclude src/pip/_vendor/six/moves
Expand Down
160 changes: 0 additions & 160 deletions docs/docs_feedback_sphinxext.py

This file was deleted.

134 changes: 134 additions & 0 deletions docs/html/architecture/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Configuration File Handling

Last updated: 21 Feb 2021

The `pip._internal.configuration` module is responsible for handling
(eg. loading from and saving values to) configuration files that are used by
pip. The module's functionality is largely exposed through and coordinated by
the module's `Configuration` class.

## Overview

pip stores configuration files in standard OS-appropriate locations, which are
determined by `appdirs`. These files are in the INI format and are processed
with `RawConfigParser`.

pip uses configuration files in two operations:

* During processing of command line options.
* Reading from *all* configuration sources
* As part of `pip config` command.
* Reading from *all* configuration sources
* Manipulating a single configuration file

Both of these operations utilize functionality provided the `Configuration`
object, which encapsulates all the logic for handling configuration files and
provides APIs for the same.

The remainder of this section documents the `Configuration` class, and
discusses potential future refactoring ideas.

## `Configuration` class

`Configuration` loads configuration values from sources in the local
environment: a combination of configuration files and environment variables.

It can be used in two "modes", for reading all the values from the local
environment and for manipulating a single configuration file. It differentiates
between these two modes using the `load_only` attribute, which can be None or
represent the {ref}`kind <config-kinds>` of the configuration file to be
manipulated.

The `isolated` attribute determines which sources are used when loading the
configuration. If `isolated` is `True`, user-specific configuration files
and environment variables are not used.

### Reading from local environment

`Configuration` can be used to read from all configuration sources in the
local environment and access the values, as per the precedence logic described
in the {ref}`Config Precedence <config-precedence>` section.

For this use case, the `Configuration.load_only` attribute would be `None`,
and the methods used would be:

```{eval-rst}
.. py:class:: Configuration
:noindex:

.. py:method:: load()

Handles all the interactions with the environment, to load all the
configuration data into objects in memory.

.. py:method:: items()

Provides key-value pairs (like ``dict.items()``) from the loaded-in-memory
information, handling all of the override ordering logic.

.. py:method:: get_value(key)

Provides the value of the given key from the loaded configuration.
The loaded configuration may have ``load_only`` be None or non-None.
This uses the same underlying mechanism as ``Configuration.items()`` and
does follow the precedence logic described in :ref:`Config Precedence
<config-precedence>`.
```

At the time of writing, the parts of the codebase that use `Configuration`
in this manner are:

* `ConfigOptionParser`, to transparently include configuration handling as part
of the command line processing logic
* `pip config get`, for printing the entire configuration when no
{ref}`kind <config-kinds>` is specified via the CLI.

### Manipulating a single configuration file

`Configuration` can be used to manipulate a single configuration file,
such as to add, change or remove certain key-value pairs.

For this use case, the `load_only` attribute would be non-None, and would
represent the {ref}`kind <config-kinds>` of the configuration file to be
manipulated. In addition to the methods discussed in the previous section,
the methods used would be:

```{eval-rst}
.. py:class:: Configuration
:noindex:

.. py:method:: get_file_to_edit()

Provides the "highest priority" file, for the {ref}`kind <config-kinds>` of
configuration file specified by `load_only`. This requires `load_only`
to be non-None.

.. py:method:: set_value(key, value)

Provides a way to add/change a single key-value pair, in the file specified
by `Configuration.get_file_to_edit()`.

.. py:method:: unset_value(key)

Provides a way to remove a single key-value pair, in the file specified
by `Configuration.get_file_to_edit()`.

.. py:method:: save()

Saves the in-memory state of to the original files, saving any modifications
made to the `Configuration` object back into the local environment.
```

## kinds

This is an enumeration that provides values to represent a "source" for
configuration. This includes environment variables and various types of
configuration files (global, site-specific, user_specific, specified via
`PIP_CONFIG_FILE`).

## Future Refactoring Ideas

* Break up the `Configuration` class into 2 smaller classes, by use case
* `Command` use-case (read only) -- `ConfigurationReader`
* `pip config` use-case (read / write) -- `ConfigurationModifier` (inherit from `ConfigurationReader`)
* Eagerly populate `Configuration._dictionary` on load.
7 changes: 7 additions & 0 deletions docs/html/architecture/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Architecture

Implementation details and stuff related to that.

```{toctree}
configuration
```
47 changes: 47 additions & 0 deletions docs/html/cli/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Commands

```{toctree}
:maxdepth: 1
:hidden:

pip
```

The general options that apply to all the commands listed below can be found [under the `pip` page in this section](pip).

```{toctree}
:maxdepth: 1
:caption: Environment management and introspection

pip_install
pip_uninstall
pip_list
pip_freeze
pip_check
```

```{toctree}
:maxdepth: 1
:caption: Fetching/Generating distributions

pip_download
pip_wheel
pip_hash
```

```{toctree}
:maxdepth: 1
:caption: Package Index information

pip_show
pip_search
```

```{toctree}
:maxdepth: 1
:caption: Managing pip itself

pip_cache
pip_config
pip_debug
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading