Skip to content

Commit 89cfa52

Browse files
committed
docs: Update autocomplete docs for click-based CLI
1 parent d40fefa commit 89cfa52

8 files changed

+109
-25
lines changed

.gitlab-ci.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,8 @@ build_docs:
527527
- docs/_build/*/*/html/*
528528
expire_in: 4 days
529529
script:
530-
- pip install . # esptool is needed for the automatic API documentation generation
530+
- pip install ".[docs]" --prefer-binary # esptool is needed for the automatic API documentation generation
531531
- cd docs
532-
- pip install -r requirements.txt --prefer-binary
533532
- build-docs -l en -t {esp8266,esp32,esp32s2,esp32c3,esp32s3,esp32c2,esp32c6,esp32h2,esp32p4,esp32c5,esp32c61}
534533

535534
.deploy_docs_template:
@@ -543,7 +542,7 @@ build_docs:
543542
- source ${CI_PROJECT_DIR}/docs/utils.sh
544543
- add_doc_server_ssh_keys $DOCS_DEPLOY_PRIVATEKEY $DOCS_DEPLOY_SERVER $DOCS_DEPLOY_SERVER_USER
545544
- export GIT_VER=$(git describe --always)
546-
- pip install -r ${CI_PROJECT_DIR}/docs/requirements.txt --prefer-binary
545+
- pip install ".[docs]" --prefer-binary
547546
- deploy-docs
548547

549548
deploy_docs_preview:

docs/conf_common.py

+3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
"esp_docs.esp_extensions.dummy_build_system",
3030
"sphinx.ext.autodoc",
3131
"sphinx.ext.napoleon",
32+
"sphinx_tabs.tabs",
3233
]
3334

35+
sphinx_tabs_disable_tab_closing = True
36+
3437
ESP8266_DOCS = []
3538

3639
ESP32_DOCS = [

docs/en/esptool/advanced-commands.rst

+12
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,18 @@ The Serial Flash Discoverable Parameters (SFDP) store essential vendor-specific
133133

134134
This will read 4 bytes from SFDP address 16.
135135

136+
.. only:: not esp8266 and not esp32
137+
138+
Read Security Info: ``get_security_info``
139+
------------------------------------------
140+
141+
The ``get_security_info`` command allows you to read security-related information (secure boot, secure download, etc.) about the Espressif devices.
142+
143+
::
144+
145+
esptool.py get_security_info
146+
147+
136148
.. only:: esp8266
137149

138150
.. _chip-id:

docs/en/installation.rst

+51-19
Original file line numberDiff line numberDiff line change
@@ -69,44 +69,76 @@ If updating directly is unavoidable, make sure you update to a compatible versio
6969

7070
$ pip install "esptool<4"
7171

72+
.. _shell-completion:
73+
7274
Shell Completions
7375
-----------------
7476

7577
To activate autocompletion, you can manually add commands provided below to your shell's config file
7678
or run them in your current terminal session for one-time activation.
7779
You will likely have to restart or re-login for the autocompletion to start working.
7880

79-
Bash
80-
^^^^
81+
.. tabs::
8182

82-
::
83+
.. group-tab:: Bash
8384

84-
eval "$(register-python-argcomplete esptool.py espsecure.py espefuse.py)"
85+
.. tabs::
8586

86-
Zsh
87-
^^^
87+
.. group-tab:: v5
8888

89-
To activate completions in zsh, first make sure `compinit` is marked for
90-
autoload and run autoload:
89+
.. code-block:: bash
9190
92-
.. code-block:: bash
91+
eval "$(_ESPTOOL_PY_COMPLETE=bash_source esptool.py espsecure.py espefuse.py)"
9392
94-
autoload -U compinit
95-
compinit
93+
.. group-tab:: v4
9694

97-
Afterwards you can enable completions for esptool.py, espsecure.py and espefuse.py:
95+
.. code-block:: bash
9896
99-
::
97+
eval "$(register-python-argcomplete esptool.py espsecure.py espefuse.py)"
10098
101-
eval "$(register-python-argcomplete esptool.py espsecure.py espefuse.py)"
99+
.. group-tab:: Zsh
102100

103-
Fish
104-
^^^^
101+
To activate completions in zsh, first make sure `compinit` is marked for
102+
autoload and run autoload:
105103

106-
Not required to be in the config file, only run once
104+
.. code-block:: bash
107105
108-
::
106+
autoload -U compinit
107+
compinit
108+
109+
Afterwards you can enable completions for esptool.py, espsecure.py and espefuse.py:
110+
111+
.. tabs::
112+
113+
.. group-tab:: v5
114+
115+
.. code-block:: bash
116+
117+
eval "$(_ESPTOOL_PY_COMPLETE=zsh_source esptool.py espsecure.py espefuse.py)"
118+
119+
.. group-tab:: v4
120+
121+
.. code-block:: bash
122+
123+
eval "$(register-python-argcomplete esptool.py espsecure.py espefuse.py)"
124+
125+
.. group-tab:: Fish
126+
127+
.. tabs::
128+
129+
.. group-tab:: v5
130+
131+
.. code-block:: bash
132+
133+
_ESPTOOL_PY_COMPLETE=fish_source esptool.py espsecure.py espefuse.py | source
134+
135+
.. group-tab:: v4
136+
137+
Not required to be in the config file, only run once
138+
139+
.. code-block:: bash
140+
141+
register-python-argcomplete --shell fish esptool.py espsecure.py espefuse.py >~/.config/fish/completions/esptool.py.fish
109142
110-
register-python-argcomplete --shell fish esptool.py espsecure.py espefuse.py >~/.config/fish/completions/esptool.py.fish
111143
112144
Other shells nor OS Windows are not supported.

docs/en/migration-guide.rst

+35
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,38 @@ All command functions (e.g., ``verify_flash``, ``write_flash``) have been refact
118118
3. Test your updated scripts to ensure compatibility with the new API.
119119

120120
For detailed examples and API reference, see the :ref:`scripting <scripting>` section.
121+
122+
123+
Flash Operations from Non-flash Related Commands
124+
************************************************
125+
126+
When esptool is used as a CLI tool, the following commands no longer automatically attach the flash by default, since flash access is not required for their core functionality:
127+
128+
- ``load_ram``
129+
- ``read_mem``
130+
- ``write_mem``
131+
- ``dump_mem``
132+
- ``chip_id``
133+
- ``read_mac``
134+
135+
The ``--spi-connection`` CLI argument has been **removed** from non-flash related commands in v5. This argument had no effect on the command execution. Affected commands:
136+
137+
- ``elf2image``
138+
- ``merge_bin``
139+
140+
**Migration Steps:**
141+
142+
1. Update any scripts that attempt to attach flash from non-flash related commands.
143+
2. If you need to attach flash for above mentioned commands, use the ``attach_flash`` function from the public API instead. For more details see :ref:`scripting <scripting>`.
144+
3. Remove the ``--spi-connection`` argument from ``elf2image`` and ``merge_bin`` commands.
145+
146+
147+
Shell Completion
148+
****************
149+
150+
The esptool ``v5`` has switched to using `Click <https://click.palletsprojects.com/>`_ for command line argument parsing, which changes how shell completion works.
151+
152+
**Migration Steps:**
153+
154+
1. Remove the old shell completion code from your scripts and shell configuration files like ``.bashrc``, ``.zshrc``, ``.config/fish/config.fish``, etc.
155+
2. Follow the new shell completion setup instructions in the :ref:`shell-completion` section of the :ref:`installation <installation>` guide.

docs/requirements.txt

-1
This file was deleted.

esptool/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,12 @@ def cli(
366366
ctx.obj.update(kwargs)
367367
ctx.obj["invoked_subcommand"] = ctx.invoked_subcommand
368368
ctx.obj["esp"] = getattr(ctx, "esp", None)
369+
log.print(f"esptool.py v{__version__}")
370+
load_config_file(verbose=True)
369371

370372

371373
def prepare_esp_object(ctx):
372374
"""Prepare ESP object for operation"""
373-
log.print(f"esptool.py v{__version__}")
374-
load_config_file(verbose=True)
375375
StubFlasher.set_preferred_stub_subdir(ctx.obj["stub_version"])
376376
# Commands that require an ESP object (flash read/write, etc.)
377377
# 1) Get the ESP object

pyproject.toml

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
"commitizen",
6060
]
6161
hsm = ["python-pkcs11"]
62+
docs = [
63+
"esp-docs~=1.10",
64+
"sphinx-tabs",
65+
]
6266

6367
[tool.setuptools]
6468
include-package-data = true

0 commit comments

Comments
 (0)