From c5dd547619c315d069b44fb475bf5456608bd2ed Mon Sep 17 00:00:00 2001 From: Anastasia Alexadrova Date: Wed, 30 Mar 2022 21:25:32 +0300 Subject: [PATCH] PG-364 Aligned docs structure with main Changed the GH action to buid a separate doc version, 1.0.x stable, from REL1_0_0 branch --- .github/workflows/doc-build.yml | 7 +- docs/_images/percona-favicon.ico | Bin 0 -> 15086 bytes docs/_images/percona-logo.svg | 12 ++ docs/css/percona.css | 16 +++ docs/css/toctree.css | 48 +++++++ docs/index.md | 48 +++++++ docs/js/version-select.js | 120 ++++++++++++++++++ docs/setup.md | 208 +++++++++++++++++++++++++++++++ mkdocs.yml | 99 +++++++++++++++ 9 files changed, 554 insertions(+), 4 deletions(-) create mode 100644 docs/_images/percona-favicon.ico create mode 100644 docs/_images/percona-logo.svg create mode 100644 docs/css/percona.css create mode 100644 docs/css/toctree.css create mode 100644 docs/index.md create mode 100644 docs/js/version-select.js create mode 100644 docs/setup.md create mode 100644 mkdocs.yml diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index d49750c..5c55f2f 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -2,7 +2,7 @@ name: Build pg_stat_monitor docs on: push: branches: - - main + - REL1_0_STABLE jobs: @@ -44,7 +44,6 @@ jobs: # Deploy docs - name: Deploy docs run: | - mike deploy main -p - mike set-default main -p - mike retitle main "latest" -p + mike deploy REL1_0_STABLE -p + mike retitle REL1_0_STABLE "1.0.x (stable)" -p diff --git a/docs/_images/percona-favicon.ico b/docs/_images/percona-favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..cabf9685ca3dcce130c64b025abbaa56d51f8417 GIT binary patch literal 15086 zcmc(l3v^V~xyR2CAaPY0LJ}Y(FcU&ZB6(2p1+Io-ZD}poTdmK6RlHRxYN-#p%CZvd zy&?)#QQNYt7rBBU3blgT+uO>dR7I$j_bUMg5)&Q<1|%VmNlt&?nc0&wXU-&NlC;fQ zzwC4N{vQ9mXXZTi-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nd)Bi7V^6 zt3k%t?(>&DG9ESdL(8@$6ZdyC+THnClXvuCj(y4So0!wL zr**_F2OjrKujHxS*&ntk_$(k^Yn+&}hOi`a@=ilDbLHchJFW#i4vow&FZAAhxXb&m z_lJiwuw6`?rZ}-AN3G;kz46>y>B^buf1J7FcF^Mx%$ap$BXg}cjhuaSF!QaE@y@yb zNFVBkjC|n8&Dd1nAB+=2Vz*1K5x4G-x@SvF=0X3Td0M>-nwV?d!My9r+@F57h;lKk zqHZUCOb;4?l-SmMcIV8`6*DLJhl1x$w}D;=Qg)M|5sR31x#HC^50}o|*rUu_9R8yUtvU7cydnzjW--d>EXxuG6_!diy&T=?uD_L{C zPw|@bp5ix}zF+cY^GnRpe9Rn84Ftl}7Ii z)V+|JR&h&en(r2lp9SfI@|RM4#P?bdT~cS{XHV8egVO($RMw~`mo?}qp7C$VUiqtF zXV^|`>)~3S|5lrx0S*7L@3qPMlk8jg3;Y#kmFapv^jwFn`MFqpYpnj*e+SNjdKPIc zeJ6NZf9;JFZ2xSs7hm%`j*%a~7fik?#&Tn9GI)pVcy4cHPm>VZkCpSmvtonq0vms0 zKOB3qmPG9FW#7xu$ljOBKKUd2@ls0PZIkB*^E2h4(s$a%^G=$=ewjZ-?D1tk#!AyZ zj59n>TpQLv_H1Nd1ir&>J}{ZJ@XsUb;nOR(dG9)OCHKq7eb77W zkc+wrBc@mGh}hvX{O0|WJ$F>~ zJ%jVgkG;tnS-WMOEXZ1%(6J_mjo6Bh_^QABMfDklOHMz{TFA*lSs$_ESF~YMu&6%D zSH<9(*pGSrtGSLYD_+GM`|9%z1{_PBw26(fmr|Z;oA^a;GaP<=n(+MxK3J)! literal 0 HcmV?d00001 diff --git a/docs/_images/percona-logo.svg b/docs/_images/percona-logo.svg new file mode 100644 index 0000000..178f62b --- /dev/null +++ b/docs/_images/percona-logo.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/docs/css/percona.css b/docs/css/percona.css new file mode 100644 index 0000000..f623fda --- /dev/null +++ b/docs/css/percona.css @@ -0,0 +1,16 @@ +[data-md-color-scheme="percona-light"] { + --md-primary-fg-color: #e97e03; + --md-primary-fg-color--light: #ECB7B7; + --md-primary-fg-color--dark: #90030C; +} +[data-md-color-scheme="slate"] { + --md-primary-fg-color: #e97e03; + /* + --md-primary-fg-color--light: #ECB7B7; + --md-primary-fg-color--dark: #90030C; + */ + --md-hue: 210; /* [0, 360] */ + } +ul li p { + margin: 0; +} \ No newline at end of file diff --git a/docs/css/toctree.css b/docs/css/toctree.css new file mode 100644 index 0000000..0de7761 --- /dev/null +++ b/docs/css/toctree.css @@ -0,0 +1,48 @@ +.sphinxsidebarwrapper { + padding-right: 0 !important; +} +/* Turns off bullets within toctree */ +.sphinxsidebarwrapper ul { + list-style: none; +} +.sphinxsidebarwrapper>ul { + padding-left: 0; +} +.sphinxsidebarwrapper>ul>li { + padding: 0 0 10px 0; + margin: 0; +} +.custom-button { + cursor: pointer; + display: inline-flex; + justify-content: center; + align-items: center; + width: 10px; + margin-right: 5px; + margin-bottom: 0; + font-size: 18px; + font-weight: 400; + border: none; + background-color: transparent; + outline: none; +} + +.custom-button~ul { + display: none; +} + +.custom-button--main-active { + background-color: #e3e3e3 +} + +.custom-button.custom-button--active~ul { + display: block; +} + +.custom-button:before { + content: '+'; +} + +.custom-button.custom-button--active:before { + content: '-'; +} diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..a76d36c --- /dev/null +++ b/docs/index.md @@ -0,0 +1,48 @@ +# Welcome + +The **pg_stat_monitor** is a **_Query Performance Monitoring_** tool for PostgreSQL. It collects performance stats and provides query performance insights in a single view. These insights allow database users to understand query origins, execution, planning statistics and details, query information, and metadata. This significantly improves observability, enabling users to debug and tune query performance. + + +## How `pg_stat_monitor` works? + +`pg_stat_monitor` is developed on the basis of `pg_stat_statements` as its more advanced replacement. While `pg_stat_statements` provides ever-increasing metrics, `pg_stat_monitor` aggregates the collected data, saving user efforts for doing it themselves. `pg_stat_monitor` stores statistics in configurable time-based units – _buckets_. Such bucket-based data collection allows focusing on statistics generated for shorter time periods and makes query timing information such as max/min/mean time more accurate. + +## Features + +* **Time Interval Grouping:** Instead of supplying one set of ever-increasing counts, `pg_stat_monitor` computes stats for a configured number of time intervals - time buckets. This allows for much better data accuracy, especially in the case of high resolution or unreliable networks. +* **Multi-Dimensional Grouping:** While `pg_stat_statements` groups counters by userid, dbid, queryid, `pg_stat_monitor` uses a more detailed group for higher precision. This allows a user to drill down into the performance of queries. +* **Capture Actual Parameters in the Queries:** `pg_stat_monitor` allows you to choose if you want to see queries with placeholders for parameters or actual parameter data. This simplifies debugging and analysis processes by enabling users to execute the same query. +* **Query Plan:** Each SQL is now accompanied by its actual plan that was constructed for its execution. That's a huge advantage if you want to understand why a particular query is slower than expected. +* **Tables Access Statistics for a Statement:** This allows us to easily identify all queries that accessed a given table. This set is at par with the information provided by the `pg_stat_statements`. +* **Histogram:** Visual representation is very helpful as it can help identify issues. With the help of the histogram function, one can now view a timing/calling data histogram in response to an SQL query. And yes, it even works in psql. + + +## Availability + +`pg_stat_monitor` supports PostgreSQL versions 11 and above. It is compatible with both PostgreSQL provided by PostgreSQL Global Development Group (PGDG) and [Percona Distribution for PostgreSQL](https://www.percona.com/software/postgresql-distribution). + + +### Supported versions + +The `pg_stat_monitor` should work on the latest version of both [Percona Distribution for PostgreSQL](https://www.percona.com/software/postgresql-distribution) and PostgreSQL, but is only tested with these versions: + +| **Distribution** | **Version** | **Provider** | +| ---------------- | --------------- | ------------ | +|[Percona Distribution for PostgreSQL](https://www.percona.com/software/postgresql-distribution)| [11](https://www.percona.com/downloads/percona-postgresql-11/LATEST/), [12](https://www.percona.com/downloads/postgresql-distribution-12/LATEST/), [13](https://www.percona.com/downloads/postgresql-distribution-13/LATEST/) and [14](https://www.percona.com/downloads/postgresql-distribution-14/LATEST/)| Percona| +| PostgreSQL | 11, 12, 13 and 14 | PostgreSQL Global Development Group (PGDG) | + +The RPM (for RHEL and CentOS) and the DEB (for Debian and Ubuntu) packages are available from Percona repositories for PostgreSQL versions [11](https://www.percona.com/downloads/percona-postgresql-11/LATEST/), [12](https://www.percona.com/downloads/postgresql-distribution-12/LATEST/), [13](https://www.percona.com/downloads/postgresql-distribution-13/LATEST/) and [14](https://www.percona.com/downloads/postgresql-distribution-14/LATEST/). + +The RPM packages are also available in the official PostgreSQL (PGDG) `yum` repositories. + +## Get started + +* Use the [installation guidelines](setup.md) to install and set up `pg_stat_monitor`. +* Refer to the [User guide](USER_GUIDE.md) for details about available features and functions, usage examples and configuration parameters. + +## Read more + +* [`pg_stat_monitor` view reference](REREFENCE.md) +* [pg_stat_monitor and pg_stat_statements comparison](COMPARE.md) + + diff --git a/docs/js/version-select.js b/docs/js/version-select.js new file mode 100644 index 0000000..dd66d6b --- /dev/null +++ b/docs/js/version-select.js @@ -0,0 +1,120 @@ +setTimeout(() => { + const asideMenu = document.getElementsByClassName('sphinxsidebarwrapper')[0]; + hideSubMenus(); + asideMenu.style.display = 'block'; +}, 500); + +function hideSubMenus() { + const asideMenu = document.getElementsByClassName('sphinxsidebarwrapper')[0]; + const activeCheckboxClass = 'custom-button--active'; + const activeBackgroundClass = 'custom-button--main-active'; + const links = Array.from(asideMenu.getElementsByTagName('a')); + const accordionLinks = links.filter(links => links.nextElementSibling && links.nextElementSibling.localName === 'ul'); + const simpleLinks = links.filter(links => !links.nextElementSibling && links.parentElement.localName === 'li'); + + simpleLinks.forEach(simpleLink => { + simpleLink.parentElement.style.listStyleType = 'disc'; + simpleLink.parentElement.style.marginLeft = '20px'; + }); + + accordionLinks.forEach((link, index) => { + insertButton(link, index); + }); + + const buttons = Array.from(document.getElementsByClassName('custom-button')); + + buttons.forEach(button => button.addEventListener('click', event => { + event.preventDefault(); + const current = event.currentTarget; + const parent = current.parentElement; + const isMain = Array.from(parent.classList).includes('toctree-l1'); + const isMainActive = Array.from(parent.classList).includes(activeBackgroundClass); + const targetClassList = Array.from(current.classList); + + toggleElement(targetClassList.includes(activeCheckboxClass), current, activeCheckboxClass); + if (isMain) { + toggleElement(isMainActive, parent, activeBackgroundClass); + } + })); + +// WIP var toctree_heading = document.getElementById("toctree-heading"); +// NOT NEEDED? asideMenu.parentNode.insertBefore(styleDomEl, asideMenu); +} + +function toggleElement(condition, item, className) { + const isButton = item.localName === 'button'; + + if (!condition) { + const previousActive = Array.from(item.parentElement.parentElement.getElementsByClassName('list-item--active')); + if (isButton) { + localStorage.setItem(item.id, 'true'); + + if (previousActive.length) { + previousActive.forEach(previous => { + + const previousActiveButtons = Array.from(previous.getElementsByClassName('custom-button--active')); + removeClass(previous, ['list-item--active', 'custom-button--main-active']); + + if (previousActiveButtons.length) { + previousActiveButtons.forEach(previousButton => { + + removeClass(previousButton, 'custom-button--active'); + localStorage.removeItem(previousButton.id); + }); + } + }) + } + } + addClass(item, className); + addClass(item.parentElement, 'list-item--active'); + } else { + removeClass(item, className); + removeClass(item.parentElement, 'list-item--active'); + + if (isButton) { + localStorage.removeItem(item.id); + } + } +} +function addClass(item, classes) { + item.classList.add(...Array.isArray(classes) ? classes : [classes]); +} +function removeClass(item, classes) { + item.classList.remove(...Array.isArray(classes) ? classes : [classes]); +} +function insertButton(element, id) { + const button = document.createElement('button'); + const isMain = Array.from(element.parentElement.classList).includes('toctree-l1'); + button.id = id; + addClass(button, 'custom-button'); + if (localStorage.getItem(id)) { + addClass(button, 'custom-button--active'); + addClass(element.parentElement, 'list-item--active'); + if (isMain) { + addClass(element.parentElement, 'custom-button--main-active'); + } + } + element.insertAdjacentElement('beforebegin', button); +} +function makeSelect() { + const custom_select = document.getElementById('custom_select'); + const select_active_option = custom_select.getElementsByClassName('select-active-text')[0]; + const custom_select_list = document.getElementById('custom_select_list'); + + select_active_option.innerHTML = window.location.href.includes('') ? + custom_select_list.getElementsByClassName('custom-select__option')[1].innerHTML : + custom_select_list.getElementsByClassName('custom-select__option')[0].innerHTML; + + document.addEventListener('click', event => { + if (event.target.parentElement.id === 'custom_select' || event.target.id === 'custom_select') { + custom_select_list.classList.toggle('select-hidden') + } + if (Array.from(event.target.classList).includes('custom-select__option')) { + select_active_option.innerHTML = event.target.innerHTML; + } + if (event.target.id !== 'custom_select' && event.target.parentElement.id !== 'custom_select') { + custom_select_list.classList.add('select-hidden') + } + + }); +} \ No newline at end of file diff --git a/docs/setup.md b/docs/setup.md new file mode 100644 index 0000000..e733b88 --- /dev/null +++ b/docs/setup.md @@ -0,0 +1,208 @@ +# Setting up `pg_stat_monitor` + +## Supported platforms + +The PostgreSQL YUM repository supports `pg_stat_monitor` for all [supported versions](#supported-versions) for the following platforms: + +* Red Hat Enterprise/Rocky/CentOS/Oracle Linux 7 and 8 +* Fedora 33 and 34 + +Find the list of supported platforms for `pg_stat_monitor` within [Percona Distribution for PostgreSQL](https://www.percona.com/software/postgresql-distribution) on the [Percona Release Lifecycle Overview](https://www.percona.com/services/policies/percona-software-support-lifecycle#pgsql) page. + + +## Installation guidelines + +You can install `pg_stat_monitor` from the following sources: + +* [Percona repositories](#installing-from-percona-repositories), +* [PostgreSQL PGDG yum repositories](#installing-from-postgresql-yum-repositories), +* [PGXN](#installing-from-pgxn) and +* [source code](#building-from-source). + + +### Installing from Percona repositories + +To install `pg_stat_monitor` from Percona repositories, you need to use the `percona-release` repository management tool. + +1. [Install percona-release](https://www.percona.com/doc/percona-repo-config/installing.html) following the instructions relevant to your operating system +2. Enable Percona repository: + +``` sh +percona-release setup ppgXX +``` + +Replace XX with the desired PostgreSQL version. For example, to install `pg_stat_monitor ` for PostgreSQL 13, specify `ppg13`. + +3. Install `pg_stat_monitor` package + + * For Debian and Ubuntu: + + ``` sh + apt-get install percona-pg-stat-monitor13 + ``` + + * For RHEL and CentOS: + + ``` sh + yum install percona-pg-stat-monitor13 + ``` + +### Installing from PostgreSQL `yum` repositories + +Install the PostgreSQL repositories following the instructions in the [Linux downloads (Red Hat family)](https://www.postgresql.org/download/linux/redhat/) chapter in PostgreSQL documentation. + +Install `pg_stat_monitor`: + +``` +dnf install -y pg_stat_monitor_ +``` + +Replace the `VERSION` variable with the PostgreSQL version you are using (e.g. specify `pg_stat_monitor_13` for PostgreSQL 13) + + +### Installing from PGXN + +You can install `pg_stat_monitor` from PGXN (PostgreSQL Extensions Network) using the [PGXN client](https://pgxn.github.io/pgxnclient/). + +Use the following command: + +``` +pgxn install pg_stat_monitor +``` + +### Building from source + +To build `pg_stat_monitor` from source code, you require the following: + +* git +* make +* gcc +* pg_config + +You can download the source code of the latest release of `pg_stat_monitor` from [the releases page on GitHub](https://github.com/Percona/pg_stat_monitor/releases) or using git: + + +``` +git clone git://github.com/Percona/pg_stat_monitor.git +``` + +Compile and install the extension + +``` +cd pg_stat_monitor +make USE_PGXS=1 +make USE_PGXS=1 install +``` + + +## Setup + +You can enable `pg_stat_monitor` when your `postgresql` instance is not running. + +`pg_stat_monitor` needs to be loaded at the start time. The extension requires additional shared memory; therefore, add the `pg_stat_monitor` value for the `shared_preload_libraries` parameter and restart the `postgresql` instance. + +Use the [ALTER SYSTEM](https://www.postgresql.org/docs/current/sql-altersystem.html)command from `psql` terminal to modify the `shared_preload_libraries` parameter. + +```sql +ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_monitor'; +``` + +> **NOTE**: If you’ve added other modules to the `shared_preload_libraries` parameter (for example, `pg_stat_statements`), list all of them separated by commas for the `ALTER SYSTEM` command. +> +>:warning: For PostgreSQL 13 and earlier versions,`pg_stat_monitor` **must** follow `pg_stat_statements`. For example, `ALTER SYSTEM SET shared_preload_libraries = 'foo, pg_stat_statements, pg_stat_monitor'`. +> +>In PostgreSQL 14, you can specify `pg_stat_statements` and `pg_stat_monitor` in any order. However, due to the extensions' architecture, if both `pg_stat_statements` and `pg_stat_monitor` are loaded, only the last listed extension captures utility queries, CREATE TABLE, Analyze, etc. The first listed extension captures most common queries like SELECT, UPDATE, INSERT, but does not capture utility queries. +> +>Thus, to collect the whole statistics with pg_stat_monitor, we recommend to specify the extensions as follows: ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements, pg_stat_monitor'. + +Start or restart the `postgresql` instance to apply the changes. + +* On Debian and Ubuntu: + +```sh +sudo systemctl restart postgresql.service +``` + +* On Red Hat Enterprise Linux and CentOS: + + +```sh +sudo systemctl restart postgresql-13 +``` + +Create the extension using the [CREATE EXTENSION](https://www.postgresql.org/docs/current/sql-createextension.html) command. Using this command requires the privileges of a superuser or a database owner. Connect to `psql` as a superuser for a database and run the following command: + + +```sql +CREATE EXTENSION pg_stat_monitor; +``` + + +This allows you to see the stats collected by `pg_stat_monitor`. + +By default, `pg_stat_monitor` is created for the `postgres` database. To access the statistics from other databases, you need to create the extension for every database. + +``` +-- Select some of the query information, like client_ip, username and application_name etc. + +postgres=# SELECT application_name, userid AS user_name, datname AS database_name, substr(query,0, 50) AS query, calls, client_ip + FROM pg_stat_monitor; + application_name | user_name | database_name | query | calls | client_ip +------------------+-----------+---------------+---------------------------------------------------+-------+----------- + psql | vagrant | postgres | SELECT application_name, userid::regrole AS user_ | 1 | 127.0.0.1 + psql | vagrant | postgres | SELECT application_name, userid AS user_name, dat | 3 | 127.0.0.1 + psql | vagrant | postgres | SELECT application_name, userid AS user_name, dat | 1 | 127.0.0.1 + psql | vagrant | postgres | SELECT application_name, userid AS user_name, dat | 8 | 127.0.0.1 + psql | vagrant | postgres | SELECT bucket, substr(query,$1, $2) AS query, cmd | 1 | 127.0.0.1 +(5 rows) +``` + +To learn more about `pg_stat_monitor` features and usage, see [User Guide](https://github.com/percona/pg_stat_monitor/blob/master/docs/USER_GUIDE.md). To view all other data elements provided by `pg_stat_monitor`, please see the [`pg_stat_monitor` view reference](REREFENCE.md). + + +## Configuration + +You can find the configuration parameters of the `pg_stat_monitor` extension in the `pg_stat_monitor_settings` view. To change the default configuration, specify new values for the desired parameters using the GUC (Grant Unified Configuration) system. To learn more, refer to the [Configuration](https://github.com/percona/pg_stat_monitor/blob/master/docs/USER_GUIDE.md#configuration) section of the user guide. + +## Remove `pg_stat_monitor` + +To uninstall `pg_stat_monitor`, do the following: + +1. Disable statistics collection. Establish the `psql` session and run the following command : + + ```sql + ALTER SYSTEM SET pg_stat_monitor.pgsm_enable = 0; + ``` + +2. Drop `pg_stat_monitor` extension: + + ```sql + DROP EXTENSION pg_stat_monitor; + ``` + +3. Remove `pg_stat_monitor` from the `shared_preload_libraries` configuration parameter: + + ```sql + ALTER SYSTEM SET shared_preload_libraries = ''; + ``` + + !!! important + + If the `shared_preload_libraries` parameter includes other modules, specify them all for the `ALTER SYSTEM SET` command to keep using them. + +4. Restart the `postgresql` instance to apply the changes. The following command restarts PostgreSQL 13. Replace the version value with the one you are using. + + * On Debian and Ubuntu: + + ```sh + sudo systemctl restart postgresql.service + ``` + + * On Red Hat Enterprise Linux and CentOS: + + + ```sh + sudo systemctl restart postgresql-13 + ``` + + diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..48a8292 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,99 @@ +# MkDocs configuration for Netlify builds + +site_name: pg_stat_monitor Documentation +site_description: Documentation +site_author: Percona LLC +copyright: Percona LLC, © 2022 + +repo_name: percona/pg_stat_monitor +repo_url: https://github.com/percona/pg_stat_monitor +edit_uri: edit/master/docs/ + +use_directory_urls: false + +# Theme for netlify testing +theme: + name: material + logo: _images/percona-logo.svg + favicon: _images/percona-favicon.ico + palette: + + # Light mode + - media: "(prefers-color-scheme: light)" + scheme: percona-light + toggle: + icon: material/toggle-switch-off-outline + name: Switch to dark mode + + # Dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + toggle: + icon: material/toggle-switch + name: Switch to light mode + +# Theme features + + features: + - search.highlight + - navigation.top + + +extra_css: + - https://unicons.iconscout.com/release/v3.0.3/css/line.css + - https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css + - css/version-select.css + - css/toctree.css + - css/percona.css + +extra_javascript: + - js/version-select.js + +markdown_extensions: + - attr_list + - toc: + permalink: True + - admonition + - footnotes + - def_list # https://michelf.ca/projects/php-markdown/extra/#def-list + - meta + - smarty: + smart_angled_quotes: true + - pymdownx.mark + - pymdownx.smartsymbols + - pymdownx.tabbed + - pymdownx.tilde + - pymdownx.superfences + - pymdownx.highlight: + linenums: false + - pymdownx.emoji: + emoji_index: !!python/name:materialx.emoji.twemoji + emoji_generator: !!python/name:materialx.emoji.to_svg + #- plantuml_markdown + +plugins: + - search + - git-revision-date + - section-index # Adds links to nodes - comment out when creating PDF +# - htmlproofer # Uncomment to check links - but extends build time significantly + - mike: + version_selector: true + css_dir: css + javascript_dir: js + canonical_version: null + + +extra: + version: + provider: mike + +nav: + - index.md + - setup.md + - User guide: + - USER_GUIDE.md + - REFERENCE.md + - COMPARISON.md + - Release notes: + - RELEASE_NOTES.md +# - Version Selector: "../" \ No newline at end of file