Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document formatting quirks of MkDocs and markdownlint #3034

Merged
merged 30 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
202bc28
docs: document formatting quirks of MkDocs and markdownlint
StackScribe Feb 13, 2024
b404722
verbage
StackScribe Feb 13, 2024
1f2397e
mkdocs.yml
StackScribe Feb 14, 2024
5a364c2
docs: document doc coding practices for our tools
StackScribe Mar 5, 2024
4e1d5e6
docmentation
StackScribe Mar 5, 2024
39331a1
code block indentation
StackScribe Mar 5, 2024
09a8221
yaml code
StackScribe Mar 5, 2024
94a4c83
Update docs/docs/contribute/docs/code-docs.md
odubajDT Mar 5, 2024
57d4b4c
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
8141489
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
50440ad
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
290a8f5
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
25373a0
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
ca45a1b
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
1667c32
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
af96787
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
0d62866
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
4330e1c
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
cf287c6
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
8a12a34
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
e551a46
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
11ee58d
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
51827fd
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
0562655
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
073e5b2
Update docs/docs/contribute/docs/source-file-structure.md
StackScribe Mar 5, 2024
b4ea0f8
Update docs/docs/contribute/docs/source-file-structure.md
StackScribe Mar 5, 2024
527212b
Update docs/docs/contribute/docs/source-file-structure.md
StackScribe Mar 5, 2024
37bed43
Update docs/docs/contribute/docs/source-file-structure.md
StackScribe Mar 5, 2024
f7cbe78
Update docs/docs/contribute/docs/code-docs.md
StackScribe Mar 5, 2024
f673359
spelling
StackScribe Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 239 additions & 0 deletions docs/docs/contribute/docs/code-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
---
comments: true
---

# Coding the docs

Keptn documentation is written using the Markdown language,
with each page written in a separate file.
The following documents document the language:

* [Markdown Guide](https://www.markdownguide.org/getting-started/#flavors-of-markdown)
discusses Markdown structure and background.
* [Basic Syntax](https://www.markdownguide.org/basic-syntax/#links)
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
summarizes the standard Markdown syntax
that is support by almost all Markdown variants.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
* [Markdown Cheat Sheet](https://www.markdownguide.org/cheat-sheet/)
is a handy reference for the most commonly used Markdown elements.

Markdown supports many variants and the build tools we use
impose a few special requirements that are discussed here.

## Top of source requirements
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

The top of each documentation source file should look like:

```markdown
---
comments: true
---

# Coding the docs

Beginning of information about the topic.

```

The elements are:

* The `comments` block.
This allows readers to post comments to the published page.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

* A level 1 header (`# title`) with the title of the page
as it is displayed in the main canvas of the docs..
This must be preceded and followed by a single blank line.

The title displayed in the left frame
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
is determined by the title in the `mkdocs.yml` file.
Be sure that these two titles match.

* Text that introduces the information for the page.
Do not use stacked headers, with a level 2 header (`## title`)
immediately following the level 1 header.

## Comments

To comment a line in the documentation,
prepend the `<!--` string at the beginning of the line,
as in:
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

```markdown
<!-- This is a comment
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
```

## Indentation of nested lists and code blocks

Paragraphs and code blocks that are nested under a list item
must be indented two spaces from the text of the list item.
If they are not,
the indented material is rendered as flush-left
and ordered lists do not increment the list item number correctly.

For example, the formatting of the bullet list in the preceding section is:

```markdown
* The `comments` block.
This allows readers to post comments to the published page.

* A level 1 header (`# title`) with the title of the page
as it is displayed in the main canvas of the docs..
This must be preceded and followed by a single blank line.

The title displayed in the left frame
is determined by the title in the `mkdocs.yml` file.
Be sure that these two titles match.

* Text that introduces the information for the page.
Do not use stacked headers, with a level 2 header (`## title`)
immediately following the level 1 header.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
```

Code blocks must be indented in the same way.

## External links and internal cross-references

Use the standard Markdown conventions for links:

```markdown
[display-string](target-link)
```

The syntax of the `target-link` is different
for external links and internal documentation cross-references.

We recommend putting the link code on a separate line in the source code.
The markdownlint tool limits the number of characters on a line.
Links are exempt from this check
but markdownlint fails the line if it includes text before or after the link.
This is not absolutely necessary if the link target is short
but this convention prevents problems.

### External links to and from documentation

Links to and from the documentation set
from outside the `NAV` path defined in the `mkdocs.yml` file
use the full URL as displayed in the browser address bar
(including the trailing `/` character)
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
for the page for the `target-link`.

This syntax is used for:

* Links from a documentation page to an external page
* Links **to** files in the same repository as the documentation source
but outside the documentation `NAV` path
* Links **from** files in the same repository as the documentation source
but outside the documentation `NAV` path,
such as `README.md` and `CONTRIBUTING.md` files

Links using a relative path to files outside the `NAV` path
resolve correctly but the targeted documentation page
does not include the contents block in the left frame.

An example of the coding for an external link is:

```markdown
The Kubernetes
[Pod](https://kubernetes.io/docs/concepts/workloads/pods/)
documentation
```

### Internal cross references in the documentation set

Internal cross-references between pages in the documentation set
(which is the documentation `NAV` path as defined in the `mkdocs.yml` file)
use a `target-link` that is a modified version
of the URL displayed for the page in the rendered documentation.

We suggest that you copy/paste the portion of the URL
that follows `docs/docs` as the base for your `target-link`.
You must then make the following modifications:

* Specify the path name of the targeted file
relative to `docs/docs` directory
using the shell convention where `../` represents
the parent directory
* Add the `.md` suffix to the file name
* Remove the trailing / from the string
* When referencing a sub-section of a page,
remove the `/` character between the page tag
and the `#` character that tags the referenced subsection.
* When referencing a section of the docs,
add the `index.md` or `_index.md` filename to the path
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

Some examples may clarify this.

#### Cross reference a file in another directory

The full URL for the `Analysis` CRD reference page is:

```shell
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
https://keptn.sh/stable/docs/reference/crd-reference/analysis/
```

To cross-reference this page
from any page in the `docs/guide` directory
(or other pages at that level), the code is:

```shell
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
See the
[Analysis](../reference/crd-reference/analysis.md)
CRD reference page.
```

To form this cross-reference::

* Copy/paste the part of the URL after `docs` as a base
* Insert `../` to go up one directory from `guides` to `docs`,
before the path that goes down the `reference/crd-reference` path
to identify the file
* Add the `.md` suffix to `Analysis` to form the actual source file name.
* Remove the trailing `/` of the URL

#### Cross-reference a sub-section of another page

To get a link to the `Examples` subsection of the `Analysis` reference page,
view the page in your browser and select `Examples`
from the contents listing in the right frame.
This gives you the following URL:

```shell
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
https://keptn.sh/stable/docs/reference/crd-reference/analysis/#examples
```

To link to that sub-section, the code is:

```shell
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
See
[Examples](../reference/crd-reference/analysis.md#examples
odubajDT marked this conversation as resolved.
Show resolved Hide resolved
```

You see that the `/` in the URL before `#examples` has been removed.

#### Cross-reference another file in the same directory

Another CRD reference page (which is in the same directory)
can reference the `Analysis` reference page
like this:

```shell
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
[Analysis](analysis.md)
```

#### Cross-reference another section

The URL of the `Installation` section is:

```shell
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
https://keptn.sh/stable/docs/installation/
```

To cross-reference this section from a file in the `guides` section
(or other file at that level),
use the relative file to the directory
and specify the `index.md` file for the section:

```shell
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
Follow the instructions in the
[Installation](installation/index.md)
section.
```
90 changes: 66 additions & 24 deletions docs/docs/contribute/docs/source-file-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,52 @@ The source files for the Keptn documentation
are stored in the same GitHub repository as the source code for the software.
This page explains how the documentation source files are organized.

> **Note** The structure of the documentation
and the source code for the documentation is evolving.
You may find small discrepancies between
what is documented here and what is currently implemented.
## Specifying the doc structure

The documentation builds are controlled by the
[mkdocs.yml](https://github.com/keptn/lifecycle-toolkit/blob/main/mkdocs.yml)
file in the root directory of the Keptn repository.
The documentation structure is defined under the `nav` section
that is roughly the second half of the file.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
The following snippet illustrates how this is structured:

```markdown
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
...
nav:
- Home:
- index.md
- Documentation:
- docs/index.md
...
- Use Cases:
- docs/use-cases/index.md
- Day 2 Operations: docs/use-cases/day-2-operations.md
- Keptn + HorizontalPodAutoscaler: docs/use-cases/hpa.md
- Keptn for non-Kubernetes deployments: docs/use-cases/non-k8s.md
...
```

* The `Home` item specifies the file for the `keptn.sh` landing page.
* The `Documentation` item is the beginning of the specification
for what files are are included and the order they will be listed.
* Each subitem to `Documentation` is a section of the docs
as displayed in the left frame.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
* Under each section are the individual pages,
listed in the order they are displayed in the left frame.
Each page line shows the title of the page
that will be displayed in the left frame
and the path to the source file.

Note that the page title displayed in the main canvas
is defined by the value of the H1 header in the page source file.
When creating a new page or modifying the title,
it is important to ensure that the title in the page source
and the title in the `mkdocs.yml` file match.
StackScribe marked this conversation as resolved.
Show resolved Hide resolved

> **Note** After adding a new page to the `mkdocs.yaml` file,
StackScribe marked this conversation as resolved.
Show resolved Hide resolved
> you must stop and restart your local doc build
> (make docs-serve)
> before the new page shows in your local build.

## Primary documentation set

Expand All @@ -22,28 +64,28 @@ the `docs/docs` directory in the repository.

The subdirectories with content are:

- `assets`: This folder is used to save assets such as code examples that are used throughout the documentation.
* `assets`: This folder is used to save assets such as code examples that are used throughout the documentation.
odubajDT marked this conversation as resolved.
Show resolved Hide resolved
Many subfolders also contain an `assets` folder,
usually containing graphics files (.png, .jpg, etc)
to keep such files closer to the content where they are referenced.
- `components`: Information about how the different subcomponents of Keptn work
- `contribute`: Contains information on how to contribute software, tests, and documentation to Keptn
- `core-concepts`: A brief overview of Keptn, its features and use cases, and its history
- `getting-started`: Hands-on exercises that demonstrate the capabilities of Keptn
- `guides`: Guides and how-to material about using Keptn features
- `installation`: Requirements and instructions for installing and enabling Keptn
- `migrate`: Information to help users who are migrating to Keptn from Keptn v1
- `reference`: Reference pages for the CRDs and APIs that Keptn provides
- `use-cases`: Examples and exercises of using Keptn in specific scenarios
* `components`: Information about how the different subcomponents of Keptn work
* `contribute`: Contains information on how to contribute software, tests, and documentation to Keptn
* `core-concepts`: A brief overview of Keptn, its features and use cases, and its history
* `getting-started`: Hands-on exercises that demonstrate the capabilities of Keptn
* `guides`: Guides and how-to material about using Keptn features
* `installation`: Requirements and instructions for installing and enabling Keptn
* `migrate`: Information to help users who are migrating to Keptn from Keptn v1
* `reference`: Reference pages for the CRDs and APIs that Keptn provides
* `use-cases`: Examples and exercises of using Keptn in specific scenarios

### Working with reference pages

The Keptn documentation includes two reference sections
that document the Keptn APIs and CRDs.
For background information, see:

- [Kubernetes API Concepts](https://kubernetes.io/docs/reference/using-api/api-concepts/)
- [Kubernetes API Reference](https://kubernetes.io/docs/reference/kubernetes-api/)
* [Kubernetes API Concepts](https://kubernetes.io/docs/reference/using-api/api-concepts/)
* [Kubernetes API Reference](https://kubernetes.io/docs/reference/kubernetes-api/)

#### API Reference

Expand All @@ -56,9 +98,9 @@ Descriptive text for the APIs is authored in the source code itself.
Each operator has its own API with different versions.
The source locations are:

- [Lifecycle API](https://github.com/keptn/lifecycle-toolkit/tree/main/lifecycle-operator/apis/lifecycle)
- [Metrics API](https://github.com/keptn/lifecycle-toolkit/tree/main/metrics-operator/api)
- [Options API](https://github.com/keptn/lifecycle-toolkit/tree/main/lifecycle-operator/apis/options)
* [Lifecycle API](https://github.com/keptn/lifecycle-toolkit/tree/main/lifecycle-operator/apis/lifecycle)
* [Metrics API](https://github.com/keptn/lifecycle-toolkit/tree/main/metrics-operator/api)
* [Options API](https://github.com/keptn/lifecycle-toolkit/tree/main/lifecycle-operator/apis/options)

The text is coded in a limited form of markdown.

Expand Down Expand Up @@ -96,12 +138,12 @@ is stored under the `docs/contribute` directory.

The subdirectories of the contribution guide are:

- **general** (General information):
* **general** (General information):
Information that is applicable to all contributors,
whether contributing software or documentation
- **software** (Software contributions):
* **software** (Software contributions):
Information that is specific to software contributions
- **docs** (Documentation contributions):
* **docs** (Documentation contributions):
Information that is specific to documentation contributions

We also have *CONTRIBUTING.md* files located in the
Expand Down Expand Up @@ -134,9 +176,9 @@ of the `mkdocs.yml` file.
Each subdirectory contains topical subdirectories for each chapter in that section.
Each topical subdirectory may contain:

- An *index.md* file that has the text for the section.
* An *index.md* file that has the text for the section.
If this is a subdirectory that contains subdirectories for other pages,
the *index.md* file
contains introductory content for the section.
- An *assets* subdirectory where graphical files for that topic are stored.
* An *assets* subdirectory where graphical files for that topic are stored.
No *assets* subdirectory is present if the topic has no graphics.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ nav:
- Build Documentation Locally: docs/contribute/docs/local-building.md
- Linter Requirements: docs/contribute/docs/linter-requirements.md
- Source File Structure: docs/contribute/docs/source-file-structure.md
- Coding the docs: docs/contribute/docs/code-docs.md
- Spell Checker: docs/contribute/docs/spell-check.md
- Published Doc Structure: docs/contribute/docs/publish.md
- Word list: docs/contribute/docs/word-list.md
Expand Down
Loading