Update to template 0.1.0

This commit is contained in:
jeanluc
2024-11-14 00:07:09 +01:00
parent 84acd4894b
commit c04b323d38
64 changed files with 96 additions and 5265 deletions

View File

@@ -1,32 +0,0 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'kitchen' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
Pathname.new(__FILE__).realpath)
bundle_binstub = File.expand_path('bundle', __dir__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort(
'Your `bin/bundle` was not generated by Bundler, ' \
'so this binstub cannot run. Replace `bin/bundle` by running ' \
'`bundle binstubs bundler --force`, then run this command again.'
)
end
end
require 'rubygems'
require 'bundler/setup'
load Gem.bin_path('test-kitchen', 'kitchen')

View File

@@ -319,7 +319,16 @@ class StateRegistry:
# given package.init, package.install and package.clean,
# only dump init and clean
parent = self.lookup(state_id[:-1], tree=True)
if len(list(x for x, y in parent.items() if not isinstance(y, dict))) == 3 and "init" in parent and "clean" in parent:
if (
len(
list(
x for x, y in parent.items() if not isinstance(y, dict)
)
)
== 3
and "init" in parent
and "clean" in parent
):
continue
yield self.states[state_id]
@@ -631,9 +640,7 @@ class DepthRenderer(Renderer):
def _render_single(self, states, prefix):
target = self._get_target(prefix)
rendr = self.delegate(
target=target, prefix=prefix, **self.opts["single_opts"]
)
rendr = self.delegate(target=target, prefix=prefix, **self.opts["single_opts"])
rendr.render(states)
def _render_index(self, states, indices, prefix=None):
@@ -712,7 +719,7 @@ class SaltAutodoc:
for file in self.glob(src):
if str(file.relative_to(self.base)).startswith(tuple(self.ignore)):
continue
with open(file, "r") as f:
with open(file) as f:
text = "".join(f.readlines())
try:
comment = self.find_comment(text)
@@ -733,8 +740,7 @@ class SaltAutodoc:
"""
Returns Path objects pointing to Salt states provided by this formula.
"""
for path in (self.base / Path(src)).rglob("*.sls"):
yield path
yield from (self.base / Path(src)).rglob("*.sls")
def find_comment(self, text):
"""
@@ -784,7 +790,10 @@ if __name__ == "__main__":
sort_list = options.get("sort_list", "auto")
if sort_list == "auto":
init = (base / "init.sls").read_text()
sort_list = ["init", "clean"] + re.findall(r"\n[^\S\n]+\-\ \.(\S+)", re.findall(r"include:((?:\n(?:[^\S\n]+|\{\%.*)\S.*)+)", init)[0])
sort_list = ["init", "clean"] + re.findall(
r"\n[^\S\n]+\-\ \.(\S+)",
re.findall(r"include:((?:\n(?:[^\S\n]+|\{\%.*)\S.*)+)", init)[0],
)
reg = StateRegistry(
avoid_init_dup=options.get("avoid_init_dup", True),