1
0
Fork 0

an simple template for my modules

Dieser Commit ist enthalten in:
Sebastian Tobie 2023-11-24 11:13:19 +01:00
Ursprung 29825a2ede
Commit 388a5b5867
8 geänderte Dateien mit 130 neuen und 0 gelöschten Zeilen

18
.editorconfig Normale Datei
Datei anzeigen

@ -0,0 +1,18 @@
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 4
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{yaml,yml}]
indent_size = 2
[Makefile]
indent_style = tab

12
Makefile Normale Datei
Datei anzeigen

@ -0,0 +1,12 @@
format:
black .
isort .
changelog:
antsibull-changelog generate
docs: format
./update_doc
release: changelog docs
ansible-galaxy collection build

32
changelogs/config.yaml Normale Datei
Datei anzeigen

@ -0,0 +1,32 @@
changelog_filename_template: ../CHANGELOG.rst
changelog_filename_version_depth: 0
changes_file: changelog.yaml
changes_format: combined
ignore_other_fragment_extensions: true
keep_fragments: false
mention_ancestor: true
new_plugins_after_name: removed_features
notesdir: fragments
prelude_section_name: release_summary
prelude_section_title: Release Summary
sanitize_changelog: true
sections:
- - major_changes
- Major Changes
- - minor_changes
- Minor Changes
- - breaking_changes
- Breaking Changes / Porting Guide
- - deprecated_features
- Deprecated Features
- - removed_features
- Removed Features (previously deprecated)
- - security_fixes
- Security Fixes
- - bugfixes
- Bugfixes
- - known_issues
- Known Issues
title: Stop50.Module
trivial_section_name: trivial
use_fqcn: true

17
galaxy.yml Normale Datei
Datei anzeigen

@ -0,0 +1,17 @@
---
namespace: stop50
name: ansible-template
version: 0.1.0
readme: README.md
authors:
- Sebastian Tobie
description: ''
license_file: 'LICENSE'
tags: []
dependencies: {}
repository: http://gitea.sebastian-tobie.de/sebastian/ansible-template.git
documentation:
issues: http://gitea.sebastian-tobie.de/sebastian/ansible-template/issues
build_ignore: []

2
meta/runtime.yml Normale Datei
Datei anzeigen

@ -0,0 +1,2 @@
---
requires_ansible: '>=2.9.10'

1
plugins/README.md Normale Datei
Datei anzeigen

@ -0,0 +1 @@
# ansible-template

7
pyproject.toml Normale Datei
Datei anzeigen

@ -0,0 +1,7 @@
[tool.black]
line-length = 140
[tool.isort]
atomic = true
profile = "black"
line_length = 140

41
update_doc Ausführbare Datei
Datei anzeigen

@ -0,0 +1,41 @@
#!/usr/bin/python
import importlib
import pathlib
import re
import sys
sys.path.append(".")
mindocstring = "DOCUMENTATION = ''''''"
moduledir = pathlib.Path("plugins/modules")
regex = re.compile("DOCUMENTATION *= *r?(?P<quote>\"{3}|'{3})(---)?.*?(?P=quote)", re.MULTILINE | re.DOTALL)
if __name__ == "__main__":
for modfile in moduledir.iterdir():
if modfile.name in ( "__init__.py", "__pycache__", "unit.py.example"):
continue
mod = importlib.import_module(".".join((modfile.parts[:-1])+(modfile.stem,)))
if hasattr(mod, "Module"):
module = mod.Module
elif hasattr(mod, "__module_name__"):
module = getattr(mod, mod.__module_name__)
else:
print("Error loading Module of File: {}. No Module or __module_name__ defined".format(modfile))
continue
try:
moddoc = module.doc()
except AttributeError:
print("Broken module. skipping {}".format(modfile))
continue
except Exception as e:
print("Error in documentation of module {}: {}".format(modfile, e))
continue
moddata = modfile.read_text()
match = regex.search(moddata)
if not match:
print("no Documentation set for module {}. Please add at least \"{}\" to the file".format(modfile.stem, mindocstring))
continue
newmod = "{pre}DOCUMENTATION = {quote}{doc}{quote}{post}".format(pre=moddata[:match.start()], quote=match.group("quote"), doc=moddoc, post=moddata[match.end():])
modfile.write_text(newmod)
print("updated the documentation of module {}".format(module.name))
# code: python