Skip to content

Commit a4fa092

Browse files
author
Lucas Fonseca
authored
[DIN-30] Update project documentations (#9)
* Update requirements * Update docs source * Update links * Update pr template
1 parent 73d296d commit a4fa092

File tree

10 files changed

+151
-52
lines changed

10 files changed

+151
-52
lines changed

.github/pull-request-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ _Please delete options that are not relevant._
2121
- [ ] Bug fix (non-breaking change which fixes an issue)
2222
- [ ] New feature (non-breaking change which adds functionality)
2323
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
24-
- [ ] This change requires a documentation update
24+
- [ ] Documentation
2525
- [ ] Release
2626

2727
## How everything was tested? :straight_ruler:

docs/requirements.docs.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ recommonmark==0.6.0
33
Sphinx==3.1.1
44
sphinx-rtd-theme==0.4.3
55
sphinxemoji==0.1.6
6-
typing-extensions==3.7.4.2
7-
thrift==0.13.0
8-
6+
typing-extensions==3.7.4.2

docs/source/conf.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Sphinx Configuration."""
12
# -*- coding: utf-8 -*-
23
#
34
# Configuration file for the Sphinx documentation builder.
@@ -22,12 +23,12 @@
2223

2324
project = "Hierarchical Conf"
2425
copyright = "2022, QuintoAndar"
25-
author = "QuintoAndar"
26+
author = "Data Engineering Team"
2627

2728
# The short X.Y version
28-
version = "0.0"
29+
version = "1.0"
2930
# The full version, including alpha/beta/rc tags
30-
release = "0.0.1"
31+
release = "1.0.0"
3132

3233

3334
# -- General configuration ---------------------------------------------------
@@ -41,20 +42,22 @@
4142
# ones.
4243
extensions = [
4344
"sphinx.ext.autodoc",
44-
"sphinx.ext.doctest",
45-
"sphinx.ext.todo",
45+
"recommonmark",
46+
"sphinx_rtd_theme",
47+
"sphinx.ext.napoleon",
4648
"sphinx.ext.coverage",
47-
"sphinx.ext.viewcode",
49+
"sphinxemoji.sphinxemoji",
4850
]
4951

52+
sphinxemoji_style = "twemoji"
53+
5054
# Add any paths that contain templates here, relative to this directory.
5155
templates_path = ["_templates"]
5256

5357
# The suffix(es) of source filenames.
5458
# You can specify multiple suffix as a list of string:
5559
#
56-
# source_suffix = ['.rst', '.md']
57-
source_suffix = ".rst"
60+
source_suffix = [".rst", ".md"]
5861

5962
# The master toctree document.
6063
master_doc = "index"
@@ -64,7 +67,7 @@
6467
#
6568
# This is also used if you do content translation via gettext catalogs.
6669
# Usually you set "language" from the command line for these cases.
67-
language = None
70+
language = "en"
6871

6972
# List of patterns, relative to source directory, that match files and
7073
# directories to ignore when looking for source files.
@@ -80,6 +83,7 @@
8083
# The theme to use for HTML and HTML Help pages. See the documentation for
8184
# a list of builtin themes.
8285
#
86+
# html_theme = 'alabaster'
8387
html_theme = "sphinx_rtd_theme"
8488

8589
# Theme options are theme-specific and customize the look and feel of a theme
@@ -133,7 +137,7 @@
133137
latex_documents = [
134138
(
135139
master_doc,
136-
"hierarchical_conf.tex",
140+
"HierarchicalConf.tex",
137141
"Hierarchical Conf Documentation",
138142
"QuintoAndar",
139143
"manual",
@@ -149,7 +153,7 @@
149153
(
150154
master_doc,
151155
"hierarchical_conf",
152-
"Hierarchical Conf Documentation",
156+
"HierarchicalConf Documentation",
153157
[author],
154158
1,
155159
)
@@ -164,10 +168,10 @@
164168
texinfo_documents = [
165169
(
166170
master_doc,
167-
"hierarchical_conf",
168-
"hierarchical_conf Documentation",
171+
"Hierarchical Conf",
172+
"Hierarchical Conf Documentation",
169173
author,
170-
"hierarchical_conf",
174+
"Hierarchical Conf",
171175
"One line description of project.",
172176
"Miscellaneous",
173177
),
@@ -193,8 +197,3 @@
193197

194198

195199
# -- Extension configuration -------------------------------------------------
196-
197-
# -- Options for todo extension ----------------------------------------------
198-
199-
# If true, `todo` and `todoList` produce output, else they produce nothing.
200-
todo_include_todos = True

docs/source/getstarted.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Getting Started
2+
3+
Hierarchical Conf depends on **Python 3.7+**.
4+
5+
[Python Package Index](https://pypi.org/project/hierarchical-conf/) hosts reference to a pip-installable module of this library, using it is as straightforward as including it on your project's requirements.
6+
7+
```bash
8+
pip install hierarchical-conf
9+
```
10+
11+
Or after listing `hierarchical-conf` in your `requirements.txt` file:
12+
13+
```bash
14+
pip install -r requirements.txt
15+
```
16+
17+
## Discovering Hierarchical Conf
18+
19+
Click on the following links to open the [examples](https://github.com/quintoandar/hierarchical-conf/tree/main/examples):
20+
21+
**[#1 Get configurations using one file](https://github.com/quintoandar/hierarchical-conf/blob/main/examples/get_conf_with_one_file.py)**
22+
23+
**[#2 Get configurations using two (or more) files](https://github.com/quintoandar/hierarchical-conf/blob/main/examples/get_conf_with_two_files.py)**
24+
25+
**[#3 Get specific configurations (runnable)](https://github.com/quintoandar/hierarchical-conf/blob/main/examples/get_specific_confs_runnable.py)**
26+
27+
**[#4 Get specific configurations with overload (runnable)](https://github.com/quintoandar/hierarchical-conf/blob/main/examples/precedence_example/get_specific_confs_with_precendence_runnable.py)**
28+
29+
30+
## Available methods
31+
32+
The features of this package can be accessed through:
33+
34+
- [`configs`](hierarchical_conf.html#hierarchical_conf.hierarchical_conf.HierarchicalConf.configs)
35+
- [`get_config`](hierarchical_conf.html#hierarchical_conf.hierarchical_conf.HierarchicalConf.get_config)

docs/source/hierarchical_conf.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
hierarchical\_conf package
2+
==========================
3+
4+
Submodules
5+
----------
6+
7+
8+
.. automodule:: hierarchical_conf.hierarchical_conf
9+
:members:
10+
:undoc-members:
11+
:show-inheritance:
12+
13+
14+
Module contents
15+
---------------
16+
17+
.. automodule:: hierarchical_conf
18+
:members:
19+
:undoc-members:
20+
:show-inheritance:

docs/source/index.rst

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,73 @@
1-
.. hierarchical_confAPIClientPython documentation master file.
1+
Hierarchical Conf
2+
===========================
3+
Made with |:heart:| by the **Data Engineering** team from `QuintoAndar <https://github.com/quintoandar/>`_.
24

3-
Welcome to Hierarchical Conf documentation!
4-
=============================================================================================
5+
A library for loading configurations (or other metadata) hierarchically based on the current environment.
6+
7+
How to use
8+
----------
9+
10+
**Short**
11+
12+
An example of how to use the library getting configurations:
13+
14+
.. code-block:: python
15+
16+
from hierarchical_conf.hierarchical_conf import HierarchicalConf
17+
18+
hierarchical_conf = HierarchicalConf(searched_paths=[PROJECT_ROOT])
19+
my_config = hierarchical_conf.get_config("my_config_key")
20+
21+
22+
**Long**
23+
24+
This tool retrieve the configurations from (YAML) files according to the current
25+
environment and files precedence.
26+
27+
It receives a list of paths and searches each one for environment configuration files in an **orderly
28+
fashion**, loading them when found and **overwriting duplicated** configuration keys by the value of the key
29+
available in the file loaded at last.
30+
The YAML configuration files are expected to be named with prefixes based on the working environment,
31+
retrieved by the value of a pre-existent operational system environment's variable named ``ENVIRONMENT``.
32+
33+
E.g.: Given the respective environments ``dev`` and ``production`` configuration files below:
34+
35+
dev_conf.yml:
36+
37+
.. code-block:: yaml
38+
39+
foo: bar_dev
40+
foo2: bar_dev2
41+
42+
production_conf.yml:
43+
44+
.. code-block:: yaml
45+
46+
foo: bar_prod
47+
foo2: bar_prod2
48+
49+
and given we are at development environment (``ENVIRONMENT=dev``), the following code will load the
50+
configuration file from the development environment file (``/my_path/dev_conf.yml``).
51+
52+
.. code-block:: python
53+
54+
hconf = HierarchicalConf(conf_files_paths=['/my_path/'])
55+
foo_conf = hconf.get_config("foo")
56+
print(foo_conf)
57+
# prints: bar_dev
58+
59+
Given ``ENVIRONMENT=production``, the code above will load the configuration file from
60+
the production environment file (``/my_path/production_conf.yml``) and print: ``bar_prod``.
61+
62+
To learn more use cases in practice (and about the keys overwriting), see `Hierarchical Conf examples <https://github.com/quintoandar/hierarchical-conf/tree/main/examples>`_.
63+
64+
65+
Navigation
66+
^^^^^^^^^^
567

668
.. toctree::
769
:maxdepth: 2
8-
:caption: Contents:
9-
1070

11-
Indices and tables
12-
==================
71+
getstarted
72+
modules
1373

14-
* :ref:`genindex`
15-
* :ref:`modindex`
16-
* :ref:`search`

docs/source/modules.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
API Specification
2+
=================
3+
4+
.. toctree::
5+
:maxdepth: 4
6+
7+
hierarchical_conf

docs/source/quintoandar_hierarchical_conf.rst

Lines changed: 0 additions & 10 deletions
This file was deleted.

hierarchical_conf/hierarchical_conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, searched_paths: List[str]) -> None:
2222

2323
@property
2424
def configs(self) -> Dict[str, Union[str, List[Any], Dict[str, Any]]]:
25-
"""All loaded configurations."""
25+
"""Returns all loaded configurations."""
2626
return self._configs.copy()
2727

2828
@property

requirements.dev.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
bump2version==0.5.11
2-
wheel==0.33.6
3-
coverage==5.5
4-
pytest==4.6.5
5-
pytest-runner==5.1
6-
pytest-cov==2.8.1
7-
Sphinx==1.8.5
8-
sphinx_rtd_theme==0.4.3
1+
twine==3.1.1

0 commit comments

Comments
 (0)