Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
sphinx-remove-toctrees
Advanced tools
Reduce your documentation build size by selectively removing toctrees from pages.
Improve your Sphinx build time by selectively removing TocTree objects from pages. This is useful if your documentation uses auto-generated API documentation, which generates a lot of stub pages.
This extension can be used to remove the sidebar links for just the pages you specify, speed up the build considerably.
This package is for maintainers that use Sphinx and have really large API documentation (or for some other reason, have a ton of nested pages). If you use a Sphinx theme that contains the entire Table of Contents on every page (e.g., any theme that has "collapsable" sidebar sections), this will slow things down considerably. Use this theme to speed up your builds.
Install the extension via pip
:
$ pip install sphinx-remove-toctrees
activate it by adding it to your Sphinx extensions in conf.py
:
extensions.append("sphinx_remove_toctrees")
In conf.py
, there is a top-level configuration key called remove_from_toctrees
that allows you to specify the pages to remove from your sidebar.
Provide a list of glob
-like paths relative to your documentation root.
Each entry should match to pages that should be removed from the sidebar.
For example, the following configuration will remove all pages from the folder api/generated
, and the specific page subfolder/page_two.rst
:
remove_from_toctrees = ["api/generated/*", "subfolder/page_two.rst"]
This is particularly useful in combination with the autosummary
directive, which tends to generate a ton of stub-pages that slows things down.
If you have the following autosummary directive in a page at myfolder/page1.rst
:
.. autosummary: datetime.datetime
:toctree: api_gen
This will generate stub-pages in a myfolder/api_gen/
folder.
To remove each of these pages from your sidebar, you would configure this extension like so:
remove_from_toctrees = ["myfolder/api_gen/*"]
This extension doesn't have a hosted documentation page, but there is one in the docs/
folder of this repository.
You can use that folder to preview this extension in action.
Sphinx keeps track of toctree
objects to represent the structure of your documentation.
These exist in the Sphinx environment object, at env.tocs
.
There are two places in the build where this is relevant here:
tocs
to ensure that files in your documentation are linked somewhere, and will raise warnings if it finds a file that is not in one of the tocs
.tocs
to build the HTML toctree
with links to pages in your documentation. If there are many elements in tocs
, it will take a long time to resolve all of these links!This extension runs after the first step, but before the second step.
It removes all the toctree
objects that you specify, so that no warnings are raised about missing files, but they are removed from the sidebar and don't slow down your build.
FAQs
Reduce your documentation build size by selectively removing toctrees from pages.
We found that sphinx-remove-toctrees demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.