### Install Vale Source: https://github.com/canonical/documentation-style-guide/blob/main/README.md Installs the Vale linter using snap. ```shell sudo snap install vale ``` -------------------------------- ### Example GitHub workflow for Vale Source: https://github.com/canonical/documentation-style-guide/blob/main/README.md An example GitHub Actions workflow to automatically run Vale checks on pull requests. ```yaml on: [pull_request] jobs: vale: name: Style checker runs-on: ubuntu-22.04 defaults: run: shell: bash working-directory: . steps: - name: Checkout repo to runner uses: actions/checkout@v3 - name: Install styles uses: canonical/documentation-style-guide@main - name: Run Vale tests uses: errata-ai/vale-action@reviewdog with: files: ./docs fail_on_error: true ``` -------------------------------- ### Separating command and output Source: https://github.com/canonical/documentation-style-guide/blob/main/docs/index.md Example demonstrating how to separate a command from its output for better readability in documentation. ```bash To check what is going on, run: juju status ... which should return some formatted information giving the current state of each unit and service: environment: gce3 machines: "0": agent-state: started agent-version: 1.24.2 ... ``` -------------------------------- ### Affix file example Source: https://github.com/canonical/documentation-style-guide/blob/main/adding-dictionary-terms.md An example block from the en_US.aff file demonstrating how a prefix is defined. ```plaintext PFX A Y 1 PFX A 0 re . ``` -------------------------------- ### Formatting Hyperlinks Source: https://github.com/canonical/documentation-style-guide/blob/main/docs/index.md Examples of correct and incorrect hyperlink formatting. ```markdown See the [formatting guidelines](#formatting) for hyperlinks. ``` ```markdown See the [Formatting section](#formatting) for guidelines about hyperlink formatting. ``` ```markdown See [Formatting](#formatting). ``` ```markdown See [this section](#formatting). ``` ```markdown [Page title](https://page-url.com) ``` ```markdown [https://page-url.com](https://page-url.com) ``` ```markdown To submit an issue related to the code, see the [Contributing guide](www.github.com/org/repo/contributing.md) on GitHub. ``` ```markdown For more information, see [How to format hyperlinks](www.external-style-guide.com/hyperlinks) ``` ```markdown First, [download file.zip](file.zip) ``` ```markdown First, download the [file](file.zip) ``` -------------------------------- ### Placeholders as environmental variables Source: https://github.com/canonical/documentation-style-guide/blob/main/docs/index.md Example demonstrating the use of environmental variables for placeholders in longer code blocks, separating user-supplied data from commands. ```default Define the channel for the charms required. For example, to select the stable release of 1.30: ``` CHANNEL=1.30/stable ``` Then proceed to fetch the required charms: ``` juju download easyrsa --channel=$CHANNEL juju download kubernetes-worker --channel=$CHANNEL ... ``` ``` -------------------------------- ### Bash code with comments Source: https://github.com/canonical/documentation-style-guide/blob/main/docs/index.md Example of bash code demonstrating the use and non-use of comments. It is recommended to explain code in prose rather than using comments within the code itself. ```bash juju deploy wordpress juju deploy ntp-master --to 2 #colocates with wordpress juju add-relation mysql wordpress ``` -------------------------------- ### Placeholder in code block Source: https://github.com/canonical/documentation-style-guide/blob/main/docs/index.md Example of a code block using placeholders for user-supplied information like instance and snapshot names. ```default lxc delete / ``` -------------------------------- ### Clone the repository Source: https://github.com/canonical/documentation-style-guide/blob/main/README.md Clones the documentation-style-guide repository locally. ```shell git clone https://github.com/canonical/documentation-style-guide.git ``` -------------------------------- ### Install uv on Ubuntu Source: https://github.com/canonical/documentation-style-guide/blob/main/HACKING.md Installs the uv package manager on Ubuntu using snap. ```bash sudo snap install astral-uv --classic ``` -------------------------------- ### Build Documentation Locally Source: https://github.com/canonical/documentation-style-guide/blob/main/README.md Builds the documentation locally. A local preview will be provided if the build is successful. ```bash make run ``` -------------------------------- ### Run Vale with configuration Source: https://github.com/canonical/documentation-style-guide/blob/main/README.md Runs Vale with a specific configuration file on a given directory. ```shell vale --config ~/documentation-style-guide/vale.ini ~/product/docs/ ``` -------------------------------- ### Specific rule configuration example Source: https://github.com/canonical/documentation-style-guide/blob/main/getting-started.md Example of how to modify the 'vale.ini' configuration file to test a specific rule by commenting out the default style and enabling a particular rule. ```ini ; BasedOnStyles = Canonical Canonical.000-My-Rule = YES ``` -------------------------------- ### Dictionary file entry example Source: https://github.com/canonical/documentation-style-guide/blob/main/adding-dictionary-terms.md An example of a dictionary entry in the .dic file, showing a base word and its associated affixes. ```plaintext base/CDRSLTG ``` -------------------------------- ### Run all test cases (uv not installed) Source: https://github.com/canonical/documentation-style-guide/blob/main/HACKING.md Sets up a virtual environment and runs all test cases when uv is not installed. ```bash cd tests python3 -m venv .venv . .venv/bin/activate pip install -e . make run ``` -------------------------------- ### Run all test cases (uv installed) Source: https://github.com/canonical/documentation-style-guide/blob/main/HACKING.md Executes all test cases for every rule when uv is installed. ```bash make -C tests run ``` -------------------------------- ### Basic Vale rule example Source: https://github.com/canonical/documentation-style-guide/blob/main/getting-started.md An example of a simple Vale rule that flags the contractions 'gonna' and 'gotta'. ```yaml extends: existence message: "Do not use the contraction '%s'" level: warning tokens: - gonna - gotta ``` -------------------------------- ### Regex Example Source: https://github.com/canonical/documentation-style-guide/blob/main/getting-started.md This YAML snippet demonstrates how to define a token to search for a specific regex pattern, like 'Not only ...but also', capturing any characters in between. ```yaml tokens: - 'not only.*?but also' ``` -------------------------------- ### Check files locally with Vale Source: https://github.com/canonical/documentation-style-guide/blob/main/README.md Commands to check individual files or directories locally using Vale. ```shell vale docs vale docs/*.md vale docs/test.md ``` -------------------------------- ### Linting Targets for Documentation Contributions Source: https://github.com/canonical/documentation-style-guide/blob/main/README.md These checks are required for landing any changes to the documentation. ```bash make spelling make lint-md make linkcheck ``` -------------------------------- ### Run selected test cases (uv installed) Source: https://github.com/canonical/documentation-style-guide/blob/main/HACKING.md Runs test cases for a specific rule (e.g., '003-Ubuntu-names-versions') using uv. ```bash uv run --directory tests pytest -vv -k 003 ``` -------------------------------- ### Confirm Vale configuration Source: https://github.com/canonical/documentation-style-guide/blob/main/README.md Commands to check if Vale configuration has been located and to see current paths. ```shell vale ls-config vale ls-vars ``` -------------------------------- ### Set environment variables for Vale Source: https://github.com/canonical/documentation-style-guide/blob/main/README.md Sets environment variables to configure Vale's paths for the configuration file and styles. ```shell export VALE_CONFIG_PATH=~/documentation-style-guide/.vale.ini export VALE_STYLES_PATH=~/documentation-style-guide/styles ``` -------------------------------- ### Jinja2 Template for Footer Navigation and Copyright Source: https://github.com/canonical/documentation-style-guide/blob/main/docs/_templates/footer.html This Jinja2 template code handles the rendering of per-page navigation (next/previous/home), copyright information, last updated date, and source links in the documentation footer. ```html {# mod: Per-page navigation #} {% if meta %} {% if 'sequential_nav' in meta %} {% set sequential_nav = meta.sequential_nav %} {% endif %} {% endif %} {# mod: Conditional wrappers to control page navigation buttons #} {% if sequential_nav != "none" -%} {% if next and (sequential_nav == "next" or sequential_nav == "both") -%}[ {{ _("Next") }} {{ next.title }} ]({{ next.link }}){%- endif %} {% if prev and (sequential_nav == "prev" or sequential_nav == "both") -%}[ {{ _("Previous") }} {% if prev.link == pathto(root_doc) %} {{ _("Home") }} {% else %} {{ prev.title }} {% endif %} ]({{ prev.link }}){%- endif %} {%- endif %} {%- if show_copyright %} {%- if hasdoc('copyright') %} {% trans path=pathto('copyright'), copyright=copyright|e -%} [Copyright]({{ path }}) © {{ copyright }} {%- endtrans %} {%- else %} {% trans copyright=copyright|e -%} Copyright © {{ copyright }} {%- endtrans %} {%- endif %} {%- endif %} {# mod: removed "Made with" #} {%- if last_updated -%} {% trans last_updated=last_updated|e -%} Last updated on {{ last_updated }} {%- endtrans -%} {%- endif %} {%- if show_source and has_source and sourcename %} [Show source]({{ pathto('_sources/' + sourcename, true)|e }}) {%- endif %} {% if has_contributor_listing and display_contributors and pagename and page_source_suffix %} {% set contributors = get_contributors_for_file(pagename, page_source_suffix) %} {% if contributors %} {% if contributors | length > 1 %} Thanks to the {{ contributors |length }} contributors! {% else %} Thanks to our contributor! {% endif %} {% for contributor in contributors %}* [{{ contributor[0] }}]({{ contributor[1] }}) {% endfor %} {% endif %} {% endif %} ``` -------------------------------- ### Run selected test cases (uv not installed) Source: https://github.com/canonical/documentation-style-guide/blob/main/HACKING.md Runs test cases for a specific rule (e.g., '003-Ubuntu-names-versions') without uv, assuming the working directory is 'tests' and the virtual environment is active. ```bash pytest -vv -k 003 ``` -------------------------------- ### Clone the repository Source: https://github.com/canonical/documentation-style-guide/blob/main/getting-started.md Cloning the repository is the first step to developing a Vale rule. ```shell git clone git@github.com:canonical/documentation-style-guide.git ``` -------------------------------- ### Test all rules command Source: https://github.com/canonical/documentation-style-guide/blob/main/getting-started.md Command to apply all rules within the 'styles/Canonical' directory to a specified file. ```shell vale test.md ``` -------------------------------- ### Google Tag Manager Initialization Source: https://github.com/canonical/documentation-style-guide/blob/main/docs/_templates/header.html This JavaScript snippet initializes Google Tag Manager by pushing an event to the dataLayer. ```javascript (function(w, d, s, l, i) { w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' }); var f = d.getElementsByTagName(s)[0]; var j = d.createElement(s); var dl = ''; if (l != 'dataLayer') { dl = '&l=' + l; } j.async = true; j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f); })(window, document, 'script', 'dataLayer', 'GTM-KNX3CJC'); ``` -------------------------------- ### Affix Definition for 'C' Source: https://github.com/canonical/documentation-style-guide/blob/main/adding-dictionary-terms.md Details the 'C' affix, showing it provides the prefix 'de' and is not combinable with other prefixes. ```plaintext PFX C Y 1 PFX C 0 de . ``` -------------------------------- ### Affix Definition for 'R' Source: https://github.com/canonical/documentation-style-guide/blob/main/adding-dictionary-terms.md Details the 'R' affix, showing it provides suffixes 'r', 'ier', or 'er' based on regex matching of the word's ending. ```plaintext SFX R Y 4 SFX R 0 r e SFX R y ier [^aeiou]y SFX R 0 er [aeiou]y SFX R 0 er [^ey] ``` -------------------------------- ### Affix Definition for 'D' Source: https://github.com/canonical/documentation-style-guide/blob/main/adding-dictionary-terms.md Details the 'D' affix, showing it provides suffixes 'd', 'ied', and 'ed' based on regex matching of the word's ending. ```plaintext SFX D Y 4 SFX D 0 d e SFX D y ied [^aeiou]y SFX D 0 ed [^ey] SFX D 0 ed [aeiou]y ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.