Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ssorj committed Jan 2, 2025
1 parent 7f7e1ac commit 1d34aef
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 34 deletions.
11 changes: 1 addition & 10 deletions python/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def generate_command(command):
append = StringBuilder()

append("---")
append(generate_command_metadata(command))
append(generate_object_metadata(command))
append("---")
append()
append(f"# {command.title_with_type}")
Expand Down Expand Up @@ -125,15 +125,6 @@ def generate_command(command):

append(command.input_file)

def generate_command_metadata(command):
data = {
"body_class": "object command",
"refdog_object_has_attributes": True,
"refdog_links": get_object_links(command),
}

return emit_yaml(data).strip()

def generate_usage(command):
parts = ["skupper"]
parts.extend([x.name for x in reversed(list(command.ancestors))])
Expand Down
19 changes: 14 additions & 5 deletions python/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
def make_fragment_id(name):
return name.lower().replace(" ", "-")

def get_object_links(obj):
def generate_object_metadata(obj):
from concepts import Concept
from resources import Resource
from commands import Command

data = list()
link_data = list()

def add_link(other):
data.append({
link_data.append({
"title": other.title_with_type,
"url": other.href.removeprefix("{{site_prefix}}"),
})
Expand All @@ -32,7 +32,7 @@ def add_link(other):
if name not in _named_links:
fail(f"{obj}: Link '{name}' not found")

data.append({
link_data.append({
"title": _named_links[name]["title"],
"url": _named_links[name]["url"],
})
Expand All @@ -49,7 +49,16 @@ def add_link(other):
for command in obj.related_commands:
add_link(command)

return data
data = {
"body_class": "object {}".format(obj.__class__.__name__.lower()),
"refdog_object_has_attributes": True,
"refdog_links": link_data,
}

if isinstance(obj, Concept):
del data["refdog_object_has_attributes"]

return emit_yaml(data).strip()

def generate_attribute_fields(attr):
rows = list()
Expand Down
10 changes: 1 addition & 9 deletions python/concepts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def generate_concept(concept):
append = StringBuilder()

append("---")
append(generate_concept_metadata(concept))
append(generate_object_metadata(concept))
append("---")
append()
append(f"# {concept.title_with_type}")
Expand All @@ -54,14 +54,6 @@ def generate_concept(concept):

append.write(concept.input_file)

def generate_concept_metadata(concept):
data = {
"body_class": "object concept",
"refdog_links": get_object_links(concept),
}

return emit_yaml(data).strip()

class ConceptModel:
def __init__(self):
notice(f"Loading {self}")
Expand Down
11 changes: 1 addition & 10 deletions python/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def generate_resource(resource):
append = StringBuilder()

append("---")
append(generate_resource_metadata(resource))
append(generate_object_metadata(resource))
append("---")
append()
append(f"# {resource.title_with_type}")
Expand Down Expand Up @@ -99,15 +99,6 @@ def generate_resource(resource):

append.write(resource.input_file)

def generate_resource_metadata(resource):
data = {
"body_class": "object resource",
"refdog_object_has_attributes": True,
"refdog_links": get_object_links(resource),
}

return emit_yaml(data).strip()

def generate_property(prop, append):
debug(f"Generating {prop}")

Expand Down

0 comments on commit 1d34aef

Please sign in to comment.