mkdocs-toggle-sidebar-plugin


Namemkdocs-toggle-sidebar-plugin JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/six-two/mkdocs-toggle-sidebar-plugin
SummaryAdd keybindings to toggle the navigation and table of contents sidebars
upload_time2024-09-10 15:12:21
maintainerNone
docs_urlNone
authorsix-two
requires_python>=3.9
licenseMIT License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mkdocs-toggle-sidebar-plugin

[![PyPI version](https://img.shields.io/pypi/v/mkdocs-toggle-sidebar-plugin)](https://pypi.org/project/mkdocs-toggle-sidebar-plugin/)
![License](https://img.shields.io/pypi/l/mkdocs-toggle-sidebar-plugin)
![Python versions](https://img.shields.io/pypi/pyversions/mkdocs-toggle-sidebar-plugin)

This package allows you to toggle the left (navigation) and right (table of contents) sidebars on a couple of MkDocs themes such as:

- [Material for MkDocs](https://github.com/squidfunk/mkdocs-material): `material`
- Builtin themes: `mkdocs`, `readthedocs`

You can play around with it and these themes on the [test page](https://mkdocs-toggle-sidebar.six-two.dev).

The settings are stored using the `localStorage` object, so that it will persist between pages.

I wrote it after getting frustrated by the browser's `Find in page` function matching way to many links in the navigation sidebar instead of searching in the actual page's content.


## Usage

### Setup

First install the PyPI package:
```bash
pip install mkdocs-toggle-sidebar-plugin
```

Add something like the following to your `mkdocs.yml`:
```yaml
plugins:
- search
- toggle-sidebar
```

### Key bindings

The plugin adds the following key bindings:

Key   | Action
---   | ---
`b` | toggle **b**oth (TOC and navigation)
`m` | toggle navigation **m**enu
`t` | toggle **T**OC

For some themes like `readthedocs` navigation and TOC are combined.
In this case the state of TOC is ignored, and only calls for navigation (or all) are interpreted.

### Toggle button

When you set the `toggle_button` option to `navigation`, `toc` or `all`, it will add a button that looks like a hamburger menu (three horizontal bars) on a theme-dependent location.
It is usually in the nav or the top bar.
Clicking the button will toggle the navigation, table of contents, or both (depending on the supplied value).
By leaving the field empty or setting it to `none`, no button is added.

### Exported API functions

This plugin exposes some JavaScript functions, that can show, hide or toggle the visibility of the sidebars.
You can see how they are called in `docs/javascript-functions.md` and how they are defined in `src/mkdocs_toggle_sidebar_plugin/toggle-sidebar.js`.

In short there are:

- `MkdocsToggleSidebarPlugin.setNavigationVisibility(show: bool)`
- `MkdocsToggleSidebarPlugin.setTocVisibility(show: bool)`
- `MkdocsToggleSidebarPlugin.setAllVisibility: (showNavigation: bool, showTOC: bool)`
- `MkdocsToggleSidebarPlugin.toggleNavigationVisibility()`
- `MkdocsToggleSidebarPlugin.toggleTocVisibility()`
- `MkdocsToggleSidebarPlugin.toggleAllVisibility()`

The names and parameters should be self-explanatory.

## Theme support

Below shows the latest themes that I have tested.
They are not updated that often, and the plugin should generally work for other of theme versions too.

Theme            | Theme version | Plugin version | Status
---              | ---           | ---            | ---
mkdocs-material  | 9.5.34        | 0.0.4          | works
mkdocs (default) | 1.6.1         | 0.0.4          | works
readthedocs      | 1.6.1         | 0.0.4          | works

Just open a issue / PR if you use a strange theme or the info above is not up to date anymore.

### Note to self

Test mkdocs-material theme:
```bash
./serve.sh
```

Test mkdocs theme:
```bash
./serve.sh --theme mkdocs
```

## Notable changes

### Version 0.0.5

- Bug fix: On small screens with the material theme the navigation would be hidden, even when the hamburger menu was opened.

### Version 0.0.4

- Export API via `MkdocsToggleSidebarPlugin` object.
    This lets you create custom buttons or key bindings to hide, show or toggle the side bars.
- Added `toggle_button` option and implemented it for Material theme.

### Version 0.0.3

- Changed internal API:
    - Element hiding/restyling is now done via CSS, so it is easier to undo. You should no longer have problems on devices with small screens (like phones) having broken layouts.

### Version 0.0.2

- Added support for `mkdocs` and `readthedocs` theme.

### Version 0.0.1

- Prototype with `mkdocs-material` implementation.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/six-two/mkdocs-toggle-sidebar-plugin",
    "name": "mkdocs-toggle-sidebar-plugin",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "six-two",
    "author_email": "pip@six-two.dev",
    "download_url": "https://files.pythonhosted.org/packages/87/fe/a16d974f300d2f48445d1196d454cdb8b9ee7b8ecf74efba98a4a46d9c24/mkdocs_toggle_sidebar_plugin-0.0.5.tar.gz",
    "platform": null,
    "description": "# mkdocs-toggle-sidebar-plugin\n\n[![PyPI version](https://img.shields.io/pypi/v/mkdocs-toggle-sidebar-plugin)](https://pypi.org/project/mkdocs-toggle-sidebar-plugin/)\n![License](https://img.shields.io/pypi/l/mkdocs-toggle-sidebar-plugin)\n![Python versions](https://img.shields.io/pypi/pyversions/mkdocs-toggle-sidebar-plugin)\n\nThis package allows you to toggle the left (navigation) and right (table of contents) sidebars on a couple of MkDocs themes such as:\n\n- [Material for MkDocs](https://github.com/squidfunk/mkdocs-material): `material`\n- Builtin themes: `mkdocs`, `readthedocs`\n\nYou can play around with it and these themes on the [test page](https://mkdocs-toggle-sidebar.six-two.dev).\n\nThe settings are stored using the `localStorage` object, so that it will persist between pages.\n\nI wrote it after getting frustrated by the browser's `Find in page` function matching way to many links in the navigation sidebar instead of searching in the actual page's content.\n\n\n## Usage\n\n### Setup\n\nFirst install the PyPI package:\n```bash\npip install mkdocs-toggle-sidebar-plugin\n```\n\nAdd something like the following to your `mkdocs.yml`:\n```yaml\nplugins:\n- search\n- toggle-sidebar\n```\n\n### Key bindings\n\nThe plugin adds the following key bindings:\n\nKey   | Action\n---   | ---\n`b` | toggle **b**oth (TOC and navigation)\n`m` | toggle navigation **m**enu\n`t` | toggle **T**OC\n\nFor some themes like `readthedocs` navigation and TOC are combined.\nIn this case the state of TOC is ignored, and only calls for navigation (or all) are interpreted.\n\n### Toggle button\n\nWhen you set the `toggle_button` option to `navigation`, `toc` or `all`, it will add a button that looks like a hamburger menu (three horizontal bars) on a theme-dependent location.\nIt is usually in the nav or the top bar.\nClicking the button will toggle the navigation, table of contents, or both (depending on the supplied value).\nBy leaving the field empty or setting it to `none`, no button is added.\n\n### Exported API functions\n\nThis plugin exposes some JavaScript functions, that can show, hide or toggle the visibility of the sidebars.\nYou can see how they are called in `docs/javascript-functions.md` and how they are defined in `src/mkdocs_toggle_sidebar_plugin/toggle-sidebar.js`.\n\nIn short there are:\n\n- `MkdocsToggleSidebarPlugin.setNavigationVisibility(show: bool)`\n- `MkdocsToggleSidebarPlugin.setTocVisibility(show: bool)`\n- `MkdocsToggleSidebarPlugin.setAllVisibility: (showNavigation: bool, showTOC: bool)`\n- `MkdocsToggleSidebarPlugin.toggleNavigationVisibility()`\n- `MkdocsToggleSidebarPlugin.toggleTocVisibility()`\n- `MkdocsToggleSidebarPlugin.toggleAllVisibility()`\n\nThe names and parameters should be self-explanatory.\n\n## Theme support\n\nBelow shows the latest themes that I have tested.\nThey are not updated that often, and the plugin should generally work for other of theme versions too.\n\nTheme            | Theme version | Plugin version | Status\n---              | ---           | ---            | ---\nmkdocs-material  | 9.5.34        | 0.0.4          | works\nmkdocs (default) | 1.6.1         | 0.0.4          | works\nreadthedocs      | 1.6.1         | 0.0.4          | works\n\nJust open a issue / PR if you use a strange theme or the info above is not up to date anymore.\n\n### Note to self\n\nTest mkdocs-material theme:\n```bash\n./serve.sh\n```\n\nTest mkdocs theme:\n```bash\n./serve.sh --theme mkdocs\n```\n\n## Notable changes\n\n### Version 0.0.5\n\n- Bug fix: On small screens with the material theme the navigation would be hidden, even when the hamburger menu was opened.\n\n### Version 0.0.4\n\n- Export API via `MkdocsToggleSidebarPlugin` object.\n    This lets you create custom buttons or key bindings to hide, show or toggle the side bars.\n- Added `toggle_button` option and implemented it for Material theme.\n\n### Version 0.0.3\n\n- Changed internal API:\n    - Element hiding/restyling is now done via CSS, so it is easier to undo. You should no longer have problems on devices with small screens (like phones) having broken layouts.\n\n### Version 0.0.2\n\n- Added support for `mkdocs` and `readthedocs` theme.\n\n### Version 0.0.1\n\n- Prototype with `mkdocs-material` implementation.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Add keybindings to toggle the navigation and table of contents sidebars",
    "version": "0.0.5",
    "project_urls": {
        "Homepage": "https://github.com/six-two/mkdocs-toggle-sidebar-plugin"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "deb1ba8b97e0de2020299232236b4530d260e271b322f2951536892d30aa0619",
                "md5": "ead13b9c98dfb5da3a4248ce2dcdfeb0",
                "sha256": "ae0d8121b2616d08970b9cf63838d7fb54f6ab738faa0eab05526890ce03ddad"
            },
            "downloads": -1,
            "filename": "mkdocs_toggle_sidebar_plugin-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ead13b9c98dfb5da3a4248ce2dcdfeb0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 10798,
            "upload_time": "2024-09-10T15:12:20",
            "upload_time_iso_8601": "2024-09-10T15:12:20.246703Z",
            "url": "https://files.pythonhosted.org/packages/de/b1/ba8b97e0de2020299232236b4530d260e271b322f2951536892d30aa0619/mkdocs_toggle_sidebar_plugin-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "87fea16d974f300d2f48445d1196d454cdb8b9ee7b8ecf74efba98a4a46d9c24",
                "md5": "da16c7974c42b8ccf3906fe67081c26e",
                "sha256": "3ee0ac7ccb32a745591adecc3ebd9bba95eee62da01cb3625c0b4f66f900596a"
            },
            "downloads": -1,
            "filename": "mkdocs_toggle_sidebar_plugin-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "da16c7974c42b8ccf3906fe67081c26e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 9888,
            "upload_time": "2024-09-10T15:12:21",
            "upload_time_iso_8601": "2024-09-10T15:12:21.576917Z",
            "url": "https://files.pythonhosted.org/packages/87/fe/a16d974f300d2f48445d1196d454cdb8b9ee7b8ecf74efba98a4a46d9c24/mkdocs_toggle_sidebar_plugin-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-10 15:12:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "six-two",
    "github_project": "mkdocs-toggle-sidebar-plugin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "mkdocs-toggle-sidebar-plugin"
}
        
Elapsed time: 0.31621s