Skip to content

Commit 778131f

Browse files
authored
New Robusta Docs (#840)
Major rewrite and improvements to Robusta docs.
1 parent 876ed31 commit 778131f

File tree

200 files changed

+5578
-3217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+5578
-3217
lines changed

CODING-CONVENTIONS.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Coding Conventions
2+
3+
The following guidelines apply to code contributions to the Robusta engine itself.
4+
5+
## Formatting
6+
7+
Robusta uses [Black](https://github.com/psf/black) and [ISort](https://pycqa.github.io/isort/) to automatically format code. Please set up Black prior so that all your contributions to Robusta will be formatted properly.
8+
9+
For instructions on using those tools with your IDE, see:
10+
11+
- [Black and ISort for VSCode](https://cereblanco.medium.com/setup-black-and-isort-in-vscode-514804590bf9)
12+
- [Black and ISort for PyCharm](https://johschmidt42.medium.com/automate-linting-formatting-in-pycharm-with-your-favourite-tools-de03e856ee17)
13+
14+
## Linting
15+
16+
Robusta uses [Flake8](https://flake8.pycqa.org/en/latest/) and [PyRight](https://github.com/microsoft/pyright) for code linting and type checking. Please set up Flake8 and PyRight prior so that all your contributions to Robusta will be linted properly.
17+
18+
For instructions on using Flake8 and PyRight tools with VSCode:
19+
20+
- [Flake8 for VSCode](https://code.visualstudio.com/docs/python/linting)
21+
- [PyRight for VSCode](https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance)
22+
23+
For instructions on using Flake8 and PyRight tools with PyCharm, see:
24+
25+
- [Installing third-party tools in PyCharm](https://www.jetbrains.com/help/pycharm/configuring-third-party-tools.html#remote-ext-tools)
26+
27+
## Pre-Commit Hooks
28+
29+
Robusta uses [pre-commit](https://pre-commit.com/) to run Black, ISort, Flake8 and PyRight (and some other minor hooks) before each commit.
30+
31+
To do so, install Robusta's dependencies with `cd src/ && poetry install` and then install the hook by running `pre-commit install`
32+
33+
## Data classes
34+
35+
Use `pydantic.BaseModel` instead of Python `dataclasses` when possible. Pydantic performs data validation whereas Python `dataclasses` just reduce boilerplate code like defining `__init__()`
36+
37+
## Imports
38+
39+
Use absolute imports whenever possible. For example, instead of `from . import foo`, use `from robusta import foo`
40+
41+
To help with that, pre-commit hook will automatically fix relative imports to absolute imports.

CONTRIBUTING.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## Contributing
2-
Any contribution is most welcome, fork the project, make changes and create a PR. We can't wait to review and merge your PR's!
2+
Contributions are welcome. Fork the project, make changes and create a PR. We can't wait to review and merge.
33

4-
* [Coding Conventions](https://docs.robusta.dev/master/developer-guide/platform/coding-conventions.html#formatting-and-coding-conventions)
5-
* [Core platform contributions](https://docs.robusta.dev/master/developer-guide/platform/dev-setup.html)
6-
* [Documentation contributions](https://docs.robusta.dev/master/developer-guide/platform/docs-contributions.html)
4+
* [Coding Conventions](./CODING-CONVENTIONS.md)
5+
* [Implementing Sinks](https://docs.robusta.dev/master/configuration/sinks/sinks-development.html)
6+
* [Implementing Actions](https://docs.robusta.dev/master/playbook-reference/actions/develop-actions/index.html)
7+
* [Improving the Docs](https://docs.robusta.dev/master/docs-contributions.html)
78
* [Issue/Feature](https://github.com/robusta-dev/robusta/issues)

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ Robusta also supports alert-remediations:
4949

5050
![](./docs/images/alert_on_hpa_reached_limit1.png)
5151

52-
[Over 50 types of automations and enrichments are built-in »](https://docs.robusta.dev/master/catalog/actions/index.html)
53-
52+
[Over 50 types of automations and enrichments are built-in »](https://docs.robusta.dev/master/playbook-reference/actions/index.html
5453
<p align="right">(<a href="#top">back to top</a>)</p>
5554

5655
## 📒 Installing Robusta
@@ -72,17 +71,17 @@ helm repo add robusta https://robusta-charts.storage.googleapis.com && helm repo
7271
helm install robusta robusta/robusta -f ./generated_values.yaml
7372
```
7473

75-
[Detailed instructions »](https://docs.robusta.dev/master/installation.html)
74+
[Detailed instructions »](https://docs.robusta.dev/master/getting-started/installation.html)
7675

7776
<!-- <p align="right">(<a href="#top">back to top</a>)</p> -->
7877

7978
## 📝 Documentation
8079
Interested? Learn more about Robusta
8180

82-
* [Architecture](https://docs.robusta.dev/master/architecture.html)
83-
* [Upgrade and Uninstall](https://docs.robusta.dev/master/upgrade.html)
84-
* [Configuration Guide](https://docs.robusta.dev/master/user-guide/configuration.html)
85-
* [Triggers](https://docs.robusta.dev/master/catalog/triggers/index.html)
81+
* [Architecture](https://docs.robusta.dev/master/how-it-works/architecture.html)
82+
* [Upgrade and Uninstall](https://docs.robusta.dev/master/setup-robusta/upgrade.html)
83+
* [Configuration Guide](https://docs.robusta.dev/master/configuration/index.html)
84+
* [Triggers](https://docs.robusta.dev/master/playbook-reference/triggers/index.html)
8685

8786
[Full documentation »](https://docs.robusta.dev/master/index.html)
8887
<p align="right">(<a href="#top">back to top</a>)</p>

docs.Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# docker build -t docs -f docs.Dockerfile .
2+
# docker run -it --rm -p 8000:8000 -v ${PWD}:/robusta docs
3+
FROM python:3.9
4+
5+
RUN curl -s https://deb.nodesource.com/setup_16.x | bash
6+
RUN apt-get update \
7+
&& apt-get install -y --no-install-recommends nodejs \
8+
&& pip3 install --no-cache-dir --upgrade pip \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
RUN curl -sSL https://install.python-poetry.org | python3 -
12+
RUN mv /root/.local/bin/poetry /usr/local/bin
13+
WORKDIR /robusta
14+
RUN poetry config virtualenvs.create false
15+
RUN pip install -U robusta-cli --no-cache
16+
COPY . /robusta/
17+
RUN poetry install --extras "all"
18+
19+
CMD ["./docs_autobuild.sh", "--host 0.0.0.0"]

docs/_ext/autorobusta.py

+6-15
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ def __document_fields(cls, fields: List[ModelField], show_code: bool, show_optio
8585
for field in fields:
8686
desc = sphinx.addnodes.desc()
8787
node.append(desc)
88+
desc["domain"] = "robusta"
89+
desc["objtype"] = "model"
8890
desc.extend(cls.__document_field_signature(field, show_optionality))
8991
desc.extend(cls.__document_field_content(field, show_code, show_optionality))
9092

@@ -114,7 +116,10 @@ def __document_field_content(cls, field: ModelField, show_code: bool, show_optio
114116
content = sphinx.addnodes.desc_content()
115117

116118
if field.field_info.description:
117-
content.append(nodes.paragraph(text=field.field_info.description))
119+
for line in field.field_info.description.splitlines():
120+
if line == "|":
121+
line = "\n"
122+
content.append(nodes.paragraph(text=line))
118123

119124
if show_code:
120125
content.extend(cls.__document_field_example(field))
@@ -335,24 +340,10 @@ def __get_ref_for_trigger(trigger_name):
335340

336341
@classmethod
337342
def __get_triggers(cls, supported_triggers: List[str], recommended_trigger: Optional[str]):
338-
if ExamplesGenerator.SUBTRIGGER_MARKER in supported_triggers:
339-
has_subtriggers = True
340-
supported_triggers.remove(ExamplesGenerator.SUBTRIGGER_MARKER)
341-
else:
342-
has_subtriggers = False
343-
344343
if recommended_trigger is not None and recommended_trigger not in supported_triggers:
345344
supported_triggers.insert(0, recommended_trigger)
346345

347346
rst = [f"* :ref:`{t} <{cls.__get_ref_for_trigger(t)}>`" for t in supported_triggers]
348-
if has_subtriggers:
349-
rst.extend(
350-
[
351-
"",
352-
"Or any other inheriting trigger. See :ref:`Trigger-Action Compatibility` for details",
353-
"",
354-
]
355-
)
356347
return rst
357348

358349
def __get_description(self, action_definition: Action):

docs/_static/analytics.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
// noinspection DuplicatedCode
44
function setupCopyListener() {
5-
let codeCells = document.querySelectorAll("pre[id^=codecell]");
5+
let codeCells = document.querySelectorAll("code");
66
codeCells.forEach(element => element.addEventListener('copy', (event) => {
77
reportCopy(element);
88
}));
9-
let copyButtons = document.querySelectorAll("button[data-clipboard-target*=codecell]");
9+
let copyButtons = document.querySelectorAll("button[data-clipboard-target*=code]");
1010
copyButtons.forEach(element => element.addEventListener('click', (event) => {
1111
reportCopy(element);
1212
}));
@@ -15,11 +15,8 @@ function setupCopyListener() {
1515
function trackPageViewEvent() {
1616
const pageUrl = window.location.href;
1717
trackEvent('DocsPageview', {'pageUrl': pageUrl});
18-
if (pageUrl.endsWith('/installation.html')) {
19-
trackEvent('InstallationPageview', {'pageUrl': pageUrl});
20-
}
21-
if (pageUrl.endsWith('/argocd-installation.html')) {
22-
trackEvent('ArgoCDInstallationPageview', {'pageUrl': pageUrl});
18+
if (pageUrl.includes('setup-robusta')) {
19+
trackEvent('NewInstallationPageview', {'pageUrl': pageUrl});
2320
}
2421
}
2522

@@ -38,8 +35,9 @@ function reportCopy(baseElement) {
3835
const path = window.location.pathname;
3936
const page = path.split("/").pop();
4037
if (page && page.endsWith('html')) {
41-
trackEvent('copied from a codeblock on: ' + page)
38+
trackEvent('copied from a codeblock in the docs');
39+
trackEvent('copied from a codeblock on: ' + page);
4240
}
43-
trackEvent('copied from codeblock: ' + id_element.getAttribute('id'))
41+
trackEvent('copied from codeblock: ' + id_element.getAttribute('id'));
4442
}
4543
}

0 commit comments

Comments
 (0)