Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Section name change, fixed conf default assignment
Browse files Browse the repository at this point in the history
Section names are now more directly in line with
https://documentation.divio.com/
  • Loading branch information
Denperidge committed May 9, 2023
1 parent e155d91 commit c23979f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Automatically collect, aggregate and structure all your [divio-style documentati
```
/{reponame}
/tutorials
/howtos
/explanations
/references
/how_to_guides
/explanation
/reference
```

On a basic level, this repo will only need a list of git url's!
Expand All @@ -16,7 +16,7 @@ On a basic level, this repo will only need a list of git url's!
- Or, if you have an how-to.md file, it'll get added in its entirety!
- Any output structure: this script generates a simple markdown tree. Nothing proprietary, no vendor-lockin. It can be generated from GitHub Actions and put into a Jekyll pages site just as easily as it is run from a Raspberry Pi and used to render the contents of an Ember application.

All you have to do is simply name your headers and/or files after the divio sections (`tutorial`, `how-to`, `explanation`, `reference`). (Oh, don't worry, the search is done through a case insensitive regex. Add more words as you please)
All you have to do is simply name your headers and/or files after the divio sections (`tutorials`, `how_to_guides`, `explanation`, `reference`). (Oh, don't worry, the search is done through a case insensitive regex. Add more words as you please)

## Getting-Started / tutorial
- Install the package (`python3 -m pip install divio_docs_gen`)
Expand Down Expand Up @@ -59,9 +59,9 @@ Further expansion could be done to this project. For example, a structure like t
/{reponame}
/0.0.1
/tutorials
/how-tos
/explanations
/references
/how_to_guides
/explanation
/reference
```
... should not be impossible to achieve with some tweaking!

Expand All @@ -77,9 +77,9 @@ This section is on the top of the file, and defines options that affect the enti
| GenerateNav | (boolean) Whether to add internal navigation to the top of each generated file. Defaults to `False` |
| DocsBasedir | What folder to output the docs in. Defaults to `docs/` |
| Tutorials | Sets the output folder name for tutorials. Defaults to `tutorials` |
| Howtos | Sets the output folder name for how-tos. Defaults to `how-tos` |
| explanations | Sets the output folder name for explanations. Defaults to `explanations` |
| references | Sets the output folder name for references. Defaults to `references` |
| how_to_guides | Sets the output folder name for how-to guides. Defaults to `how_to_guides` |
| explanation | Sets the output folder name for explanation. Defaults to `explanation` |
| reference | Sets the output folder name for reference. Defaults to `reference` |


#### [repo] section
Expand All @@ -93,7 +93,7 @@ You can add as many of these as you want. Each one represents a repo you want pa


**Example Ignore:** `Ignore=building-a-template.md//why-semantic-microservices.md`
**Example Move:** `Move=documentation.md/references`
**Example Move:** `Move=documentation.md/reference`


*Note: for `Move` and `Ignore` you can choose to be more specific by writing `sub/folder/filename.md`. The check is a `provided_path in full_filepath`, so `sub/folder/filename.md` will apply to `even/further/sub/folder/filename.md`.*
Expand All @@ -107,7 +107,7 @@ For ease of use and freedom of implementation, every section has synonyms.
| Section | Synonyms |
| ------------- | ------------------------------- |
| Tutorials | Getting started |
| How-To's | How-To, Guide, Usage |
| How-to Guides | How-To, Guide, Usage |
| Explanation | Discussion, background material |
| Reference | Technical |

Expand Down
8 changes: 4 additions & 4 deletions docs.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ docsbasedir = docs/

[Naming Scheme]
tutorials = Tutorials
howtos = How-To
explanations = Explanations
references = Reference
how_to_guides = How-Tos
explanation = explanation
reference = Reference

[Repository Selection]

Expand All @@ -16,5 +16,5 @@ url = https://github.com/mu-semtech/mu-cl-resources

[https://github.com/denperidge-redpencil/project]
url = https://github.com/denperidge-redpencil/project
Move=documentation.md/references
Move=documentation.md/reference
Ignore=building-a-template.md//why-semantic-microservices.md
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "divio_docs_gen"
version = "0.2.0"
version = "0.2.1"
authors = [
{ name="Denperidge", email="denperidge@gmail.com" },
]
Expand Down
28 changes: 14 additions & 14 deletions src/divio_docs_gen/Args.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

"""Code to handle configuration, through docs.conf or args"""

section_keys = ["tutorials", "howtos", "explanations", "references"]
section_keys = ["tutorials", "how_to_guides", "explanation", "reference"]
class Args:
def __init__(self) -> None:
# store_true default is False, which means save_conf's output will be too verbose. Use None instead
Expand All @@ -14,7 +14,7 @@ def __init__(self) -> None:
self.docs_basedir = "docs/"
self.generate_nav = None

self.tutorials, self.howtos, self.explanations, self.references = section_keys
self.tutorials, self.how_to_guides, self.explanation, self.reference = section_keys

self.repos = []

Expand All @@ -23,11 +23,11 @@ def get_configured_section_name(self, section_id: str):
if section_id == section_keys[0]:
return self.tutorials
elif section_id == section_keys[1]:
return self.howtos
return self.how_to_guides
elif section_id == section_keys[2]:
return self.explanations
return self.explanation
elif section_id == section_keys[3]:
return self.references
return self.reference
print(section_id)


Expand All @@ -42,9 +42,9 @@ def __str__(self) -> str:
- generate_nav: {self.generate_nav}
- tutorials: {self.tutorials}
- howtos: {self.howtos}
- explanations: {self.explanations}
- references: {self.references}
- how_to_guides: {self.how_to_guides}
- explanation: {self.explanation}
- reference: {self.reference}
- repos: {self.repos}
"""
Expand Down Expand Up @@ -130,7 +130,7 @@ def __repr__(self) -> str:

""" Get config, save if desired, apply"""
def get_conf_value(section_id, value_id):
return conf[section_id][value_id] if value_id in conf[section_id] else ""
return conf[section_id][value_id] if value_id in conf[section_id] else None

def get_cli_arg_value(value_id):
return getattr(cli_args, value_id) if hasattr(cli_args, value_id) else None
Expand All @@ -142,7 +142,7 @@ def get_value(section_id, value_id, default):
# If it's undefined in the CLI, check if conf can be used
if value is None and use_conf:
value = get_conf_value(section_id, value_id)
elif value is None:
if value is None:
value = default

if args.save_conf:
Expand All @@ -155,17 +155,17 @@ def get_value(section_id, value_id, default):
args.generate_nav = bool(get_value(conf_sections["output"], "GenerateNav", False))
args.docs_basedir = get_value(conf_sections["output"], "DocsBasedir", "docs/")

for i, section_name in enumerate(["tutorials", "howtos", "explanations", "references"]):
for i, section_name in enumerate(["tutorials", "how_to_guides", "explanation", "reference"]):
# TODO cleaner solution
value = get_value(conf_sections["naming"], value_id=section_name, default=section_name)
if i == 0:
args.tutorials = value
elif i == 1:
args.howtos = value
args.how_to_guides = value
elif i == 2:
args.explanations = value
args.explanation = value
elif i == 3:
args.references = value
args.reference = value


if get_cli_arg_value("repos"):
Expand Down
8 changes: 4 additions & 4 deletions src/divio_docs_gen/Section.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from re import search, RegexFlag, sub, escape
from .Args import args

"""Defines section (how-to, getting started...) classes"""
"""Defines section (how_to_guides, tutorials...) classes"""

def regex(needle: r"str", haystack: str, flags):
"""Base regex helper"""
Expand Down Expand Up @@ -118,9 +118,9 @@ def lower_header(match):
"""Section definitions. This is where you can customise synonyms"""
sections = {
"tutorials": Section(args.tutorials, r"(tutorial|getting\W*started)"),
"howtos": Section(args.howtos, r"(how\W*to|guide|usage)"),
"explanations": Section(args.explanations, r"(explanation|discussion|background\W*material)"),
"references": Section(args.references, r"(reference|technical)")
"how_to_guides": Section(args.how_to_guides, r"(how\W*to|guide|usage)"),
"explanation": Section(args.explanation, r"(explanation|discussion|background\W*material)"),
"reference": Section(args.reference, r"(reference|technical)")
}


Expand Down

0 comments on commit c23979f

Please sign in to comment.