Skip to content

Commit 028426c

Browse files
committed
Update the documentation (#3)
1 parent 7b38705 commit 028426c

Some content is hidden

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

59 files changed

+7677
-14
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
--wheel
4242
--outdir dist/
4343
44+
- name: Update the GitHub pages documentation
45+
run: cd docs && mkdocs gh-deploy --force && cd ..
46+
4447
- name: Publish distribution package to PyPI
4548
if: startsWith(github.ref, 'refs/tags')
4649
uses: pypa/gh-action-pypi-publish@master

.github/workflows/pull-request-checks.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,16 @@ jobs:
9797
if: steps.check_files.outputs.files_exists == 'false'
9898
run: coverage-badge -o docs/coverage.svg -f
9999

100+
- name: Generate documentation
101+
run: pydoc-markdown --render-toc && mv build/docs/* docs
102+
100103
- name: Commit files
101104
if: steps.check_files.outputs.files_exists == 'false'
102105
run: |
103106
git config --local user.email "github-actions[bot]@users.noreply.github.com"
104107
git config --local user.name "github-actions[bot]"
105-
git add --force docs/coverage.svg
106-
git commit -m "Add coverage badge"
108+
git add --force docs
109+
git commit -m "Add coverage badge and documentation"
107110
108111
- name: Push changes
109112
if: steps.check_files.outputs.files_exists == 'false'
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Table of Contents
2+
3+
* [grafana\_dashboard.dashboard](#grafana_dashboard.dashboard)
4+
* [Dashboard](#grafana_dashboard.dashboard.Dashboard)
5+
* [get\_dashboard\_json](#grafana_dashboard.dashboard.Dashboard.get_dashboard_json)
6+
7+
<a id="grafana_dashboard.dashboard"></a>
8+
9+
# grafana\_dashboard.dashboard
10+
11+
<a id="grafana_dashboard.dashboard.Dashboard"></a>
12+
13+
## Dashboard Objects
14+
15+
```python
16+
class Dashboard()
17+
```
18+
19+
The class includes all necessary methods to template the selected dashboard and return it as a dict
20+
21+
**Arguments**:
22+
23+
- `dashboard_model` _Model_ - Inject a dashboard object that includes all necessary values and information
24+
25+
26+
**Attributes**:
27+
28+
- `dashboard_model` _Model_ - This is where we store the model
29+
- `logging` _logging.Logger_ - This is where we store the logger
30+
31+
<a id="grafana_dashboard.dashboard.Dashboard.get_dashboard_json"></a>
32+
33+
#### get\_dashboard\_json
34+
35+
```python
36+
def get_dashboard_json(template_values: dict) -> dict
37+
```
38+
39+
The method includes a functionality to template the selected dashboard and return the corresponding dashboard
40+
as dictionary
41+
42+
**Arguments**:
43+
44+
- `template_values` _dict_ - Specify the inserted templating values as dict
45+
46+
47+
**Raises**:
48+
49+
- `Exception` - Unspecified error by executing the functionality
50+
51+
52+
**Returns**:
53+
54+
- `json_dashboard` _dict_ - Returns the dashboard as dict
55+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Table of Contents
2+
3+
* [grafana\_dashboard.model](#grafana_dashboard.model)
4+
* [Model](#grafana_dashboard.model.Model)
5+
6+
<a id="grafana_dashboard.model"></a>
7+
8+
# grafana\_dashboard.model
9+
10+
<a id="grafana_dashboard.model.Model"></a>
11+
12+
## Model Objects
13+
14+
```python
15+
class Model()
16+
```
17+
18+
The class includes all necessary variables to specify a query for the datasource search endpoint
19+
20+
**Arguments**:
21+
22+
- `dashboard_templates_path` _str_ - Specify the template path for all dashboard's (default None)
23+
- `dashboard_type` _str_ - Specify the dashboard type e.g. database (default None)
24+
- `dashboard_name` _str_ - Specify the dashboard name e.g. postgres (default None)
25+
- `dashboard_version` _str_ - Specify the dashboard version e.g. v13 (default None)
26+

docs/content/index.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Grafana Dashboard Templater
2+
The Grafana dashboard templater create a valid Grafana dashboard as dictionary based on a template and injected values.
3+
4+
## Dashboard template folder structure
5+
6+
```
7+
dashboard-templates <- Folder of the dashboard templates
8+
database <- Dashboard type
9+
postgresql <- Dashboard name
10+
v13 <- Dashboard version
11+
dashboard.json.sample <- Dashboard template
12+
```
13+
14+
## Installation
15+
16+
`pip install grafana-dashboard-templater`
17+
18+
## Example
19+
20+
```python
21+
from grafana_dashboard.model import Model
22+
from grafana_dashboard.dashboard import Dashboard
23+
24+
dashboard_model: Model = Model(dashboard_templates_path="./dashboard-templates", dashboard_type="database",
25+
dashboard_name="postgresql", dashboard_version="v13")
26+
27+
dashboard: Dashboard = Dashboard(dashboard_model)
28+
dashboard_json = dashboard.get_dashboard_json(template_values={"app_name": "PostgreSQL", "prometheus_name": "k8s-sonarqube-postgresql"})
29+
```
30+
31+
## Grafana API SDK
32+
If you want to establish a connection to Grafana API via an SDK you can check out one of my other [project](https://github.com/ZPascal/grafana_api_sdk) and integrate the functionality inside your code.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Grafana Dashboard Templater
2+
The Grafana dashboard templater create a valid Grafana dashboard as dictionary based on a template and injected values.
3+
4+
## Dashboard template folder structure
5+
6+
```
7+
dashboard-templates <- Folder of the dashboard templates
8+
database <- Dashboard type
9+
postgresql <- Dashboard name
10+
v13 <- Dashboard version
11+
dashboard.json.sample <- Dashboard template
12+
```
13+
14+
## Installation
15+
16+
`pip install grafana-dashboard-templater`
17+
18+
## Example
19+
20+
```python
21+
from grafana_dashboard.model import Model
22+
from grafana_dashboard.dashboard import Dashboard
23+
24+
dashboard_model: Model = Model(dashboard_templates_path="./dashboard-templates", dashboard_type="database",
25+
dashboard_name="postgresql", dashboard_version="v13")
26+
27+
dashboard: Dashboard = Dashboard(dashboard_model)
28+
dashboard_json = dashboard.get_dashboard_json(template_values={"app_name": "PostgreSQL", "prometheus_name": "k8s-sonarqube-postgresql"})
29+
```
30+
31+
## Grafana API SDK
32+
If you want to establish a connection to Grafana API via an SDK you can check out one of my other [project](https://github.com/ZPascal/grafana_api_sdk) and integrate the functionality inside your code.

docs/mkdocs.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
docs_dir: content
2+
nav:
3+
- Home: index.md
4+
- Grafana Dashboard Templater Documentation:
5+
- Model: grafana_dashboard_templater/model.md
6+
- Dashboard: grafana_dashboard_templater/dashboard.md
7+
repo_url: https://github.com/ZPascal/grafana_dashboard_templater
8+
site_name: Grafana Dashboard Templater
9+
theme: readthedocs

docs/site/404.html

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<!DOCTYPE html>
2+
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
3+
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
4+
<head>
5+
<meta charset="utf-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
9+
10+
11+
<link rel="shortcut icon" href="/img/favicon.ico">
12+
<title>Grafana Dashboard Templater</title>
13+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700" />
14+
15+
<link rel="stylesheet" href="/css/theme.css" />
16+
<link rel="stylesheet" href="/css/theme_extra.css" />
17+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" />
18+
19+
<script src="/js/jquery-2.1.1.min.js" defer></script>
20+
<script src="/js/modernizr-2.8.3.min.js" defer></script>
21+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
22+
<script>hljs.initHighlightingOnLoad();</script>
23+
</head>
24+
25+
<body class="wy-body-for-nav" role="document">
26+
27+
<div class="wy-grid-for-nav">
28+
29+
30+
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
31+
<div class="wy-side-scroll">
32+
<div class="wy-side-nav-search">
33+
<a href="/." class="icon icon-home"> Grafana Dashboard Templater</a>
34+
<div role="search">
35+
<form id ="rtd-search-form" class="wy-form" action="//search.html" method="get">
36+
<input type="text" name="q" placeholder="Search docs" title="Type search term here" />
37+
</form>
38+
</div>
39+
</div>
40+
41+
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
42+
<ul>
43+
<li class="toctree-l1"><a class="reference internal" href="/.">Home</a>
44+
</li>
45+
</ul>
46+
<p class="caption"><span class="caption-text">Grafana Dashboard Templater Documentation</span></p>
47+
<ul>
48+
<li class="toctree-l1"><a class="reference internal" href="/grafana_dashboard_templater/model/">Model</a>
49+
</li>
50+
<li class="toctree-l1"><a class="reference internal" href="/grafana_dashboard_templater/dashboard/">Dashboard</a>
51+
</li>
52+
</ul>
53+
</div>
54+
</div>
55+
</nav>
56+
57+
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
58+
59+
60+
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
61+
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
62+
<a href="/.">Grafana Dashboard Templater</a>
63+
</nav>
64+
65+
66+
<div class="wy-nav-content">
67+
<div class="rst-content">
68+
<div role="navigation" aria-label="breadcrumbs navigation">
69+
<ul class="wy-breadcrumbs">
70+
<li><a href="/.">Docs</a> &raquo;</li>
71+
72+
73+
<li class="wy-breadcrumbs-aside">
74+
75+
</li>
76+
</ul>
77+
78+
<hr/>
79+
</div>
80+
81+
<div role="main">
82+
<div class="section">
83+
84+
85+
<h1 id="404-page-not-found">404</h1>
86+
87+
<p><strong>Page not found</strong></p>
88+
89+
90+
</div>
91+
</div>
92+
<footer>
93+
94+
95+
<hr/>
96+
97+
<div role="contentinfo">
98+
<!-- Copyright etc -->
99+
100+
</div>
101+
102+
Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
103+
</footer>
104+
105+
</div>
106+
</div>
107+
108+
</section>
109+
110+
</div>
111+
112+
<div class="rst-versions" role="note" aria-label="versions">
113+
<span class="rst-current-version" data-toggle="rst-current-version">
114+
115+
<span>
116+
<a href="https://github.com/ZPascal/grafana_dashboard_templater/" class="fa fa-github" style="color: #fcfcfc"> GitHub</a>
117+
</span>
118+
119+
120+
121+
</span>
122+
</div>
123+
<script>var base_url = '/';</script>
124+
<script src="/js/theme_extra.js" defer></script>
125+
<script src="/js/theme.js" defer></script>
126+
<script src="/search/main.js" defer></script>
127+
<script defer>
128+
window.onload = function () {
129+
SphinxRtdTheme.Navigation.enable(true);
130+
};
131+
</script>
132+
133+
</body>
134+
</html>

docs/site/css/theme.css

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)