Skip to content

fix(docs): system parameters schema and cue definition #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f47890b
fix(docs): correct python type annotations in documentation generator…
stevenj May 15, 2025
3ffc8e5
docs(docs): Better define the document encoding restrictions. (#326)
stevenj May 16, 2025
15683fa
fix(docs): system parameters schema and cue definition
nathanbogale May 19, 2025
58e1be5
fix(docs): parameter json and cue structure
nathanbogale May 19, 2025
04d8238
fix (docs): decision reference to brand and overall structure
nathanbogale May 19, 2025
cb28dec
fix(docs): cue files fixed - path wip
nathanbogale May 19, 2025
f1ae914
fix(docs): fixed instabilities with the signed document generation
nathanbogale May 20, 2025
4973d39
feat(docs): Add examples for predefined document schemas
stevenj May 20, 2025
fb6b392
Merge branch 'main' into feat/add-payload-examples
stevenj May 20, 2025
2971d72
Merge branch 'main' into feat/signed-doc-spec-0.04
stevenj May 20, 2025
e2d902d
Merge branch 'feat/signed-doc-spec-0.04' into feat/add-payload-examples
stevenj May 20, 2025
e4d0819
feat(docs): Add examples for predefined document schemas (#342)
stevenj May 21, 2025
9feb9a5
Merge branch 'feat/signed-doc-spec-0.04' into feat/system-parameters
stevenj May 21, 2025
757c07a
Merge branch 'feat/add-payload-examples' into feat/system-parameters
nathanbogale May 21, 2025
aae4675
fix(docs): stable document regeneration
nathanbogale May 21, 2025
0023a5e
fix(docs): schema and example updated and stable for brands, campaign…
nathanbogale May 22, 2025
2bc1917
fix(docs): added a central and reusable definition json for schema re…
nathanbogale May 26, 2025
eff33eb
fix(docs): updated template reference and usage
nathanbogale Jun 1, 2025
4758bfb
fix(docs): simplified parameter documents, removed payload
nathanbogale Jun 19, 2025
0b6addd
fix(docs): document regenerated after payload removal
nathanbogale Jun 19, 2025
20d5ac6
Merge branch 'main' into feat/signed-doc-spec-0.04
stevenj Jun 21, 2025
c4e2fc3
Merge branch 'feat/signed-doc-spec-0.04' into feat/system-parameters
stevenj Jun 21, 2025
719e9ff
fix(docs): added a list of captured parameters
nathanbogale Jun 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .vscode/settings.recommended.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
// Recommended `settings.json` configuration
"$comment": "Recommended `settings.json` configuration",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true,
Expand Down Expand Up @@ -37,12 +37,20 @@
"rust",
"rust/c509-certificate",
"rust/cardano-chain-follower",
"rust/catalyst-types",
"rust/catalyst-voting",
"rust/immutable-ledger",
"rust/vote-tx-v1",
"rust/vote-tx-v2",
"rust/signed-doc",
"rust/cbork",
"rust/hermes-ipfs",
"rust/rbac-registration",
"rust/cardano-blockchain-types",
"dart",
"docs",
"general"
"general",
"deps"
],
"conventionalCommits.gitmoji": false,
"markdown.extension.toc.unorderedList.marker": "*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
digraph "None" {
digraph "All" {
rankdir="LR"
graph [fontname="helvetica", fontsize="32", fontcolor="#29235c", bgcolor="white"];
node [penwidth="0", margin="0", fontname="helvetica", fontsize="32", fontcolor="#29235c"];
Expand Down
6 changes: 3 additions & 3 deletions specs/gen_docs/gen/doc_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def add_reference_links(self) -> None:

actual_link_names = self._spec.link_names()

actual_links_used = {}
actual_links_used: dict[str, str] = {}
for link_name in actual_link_names:
esc_link_name = re.escape(link_name)
link_name_regex = f"(^|\\s)({esc_link_name})(\\.|\\s|$)"
Expand All @@ -190,7 +190,7 @@ def add_reference_links(self) -> None:
for link, actual in actual_links_used.items():
self._filedata += f"\n[{link}]: {actual}"

def remove_tabs(self, tabstop: int = 4) -> str:
def remove_tabs(self, tabstop: int = 4) -> None:
"""Replace tabs in the input text with spaces so that the text aligns on tab stops.

Args:
Expand Down Expand Up @@ -343,7 +343,7 @@ def file_name(self) -> str:
"""Return the files name."""
return self._filename

def file_path(self, relative_doc: typing.Self | None = None) -> Path:
def file_path(self, relative_doc: "DocGenerator | None" = None) -> Path:
"""Return a path to the file."""
if relative_doc is not None:
relative_path = relative_doc.file_path().parent
Expand Down
4 changes: 2 additions & 2 deletions specs/gen_docs/gen/doc_relationship_diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def generate(self) -> bool: # noqa: C901
file_title = textwrap.fill(f"{file_id} Document Relationships", width=30)

dot_file = DotFile(
self._document_name, file_title, depth=self._depth, title_size=150 if self._document_name is None else 50
file_id, file_title, depth=self._depth, title_size=150 if self._document_name is None else 50
)

all_dst_refs: list[str] = []
Expand All @@ -66,7 +66,7 @@ def generate(self) -> bool: # noqa: C901
doc_data = self._spec.get_document(doc)

# Add content type explicitely to table.
doc_table.add_row(TableRow(name="content type", value=doc_data.headers["content type"].value))
doc_table.add_row(TableRow(name="content type", value=doc_data.content_type))

# Add all used Metadata to table.
for meta in self._spec.all_headers(HeaderType.METADATA):
Expand Down
39 changes: 24 additions & 15 deletions specs/gen_docs/gen/graphviz_doc_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ class TableRow(BaseModel):

model_config = ConfigDict(extra="forbid")

@classmethod
def default_list(cls) -> list["TableRow"]:
"""Return a default list of this class."""
return []

def generate(self, bgcolor: str) -> str:
"""Generate a single row of the table."""
value = self.value
Expand Down Expand Up @@ -171,14 +176,15 @@ def from_doc_cluster(cls, cluster: DocCluster | None) -> "Cluster | None":
return None
return cls(name=cluster.name)

@property
def label(self) -> str:
"""Transform the name into a label."""
return "cluster_" + self.name.lower().replace(" ", "_").replace("-", "_")

def start(self) -> str:
"""Start a new cluster."""
return f"""
subgraph {self.label()} {{
subgraph {self.label} {{
label = "{self.name}";
color=blue
penwidth=20
Expand All @@ -188,7 +194,7 @@ def end(self) -> str:
"""End the cluster."""
return "}\n"

def __eq__(self, other: "Cluster") -> bool:
def __eq__(self, other: object) -> bool:
"""Eq."""
if not isinstance(other, Cluster):
# don't attempt to compare against unrelated types
Expand All @@ -203,7 +209,7 @@ class DotSignedDoc(BaseModel):
title_port: str = Field(default="title")
title_href: str | None = Field(default=None)
theme: TableTheme = Field(default_factory=TableTheme)
rows: list[TableRow] = Field(default_factory=list)
rows: list[TableRow] = Field(default_factory=TableRow.default_list)
cluster: Cluster | None = Field(default=None)

model_config = ConfigDict(extra="forbid")
Expand Down Expand Up @@ -296,6 +302,11 @@ def is_cluster(self) -> bool:
"""Is the link to a cluster."""
return isinstance(self.port, Cluster)

@property
def port_label(self) -> str | None:
"""Get label of the port."""
return self.port.label if self.is_cluster else None # type: ignore # noqa: PGH003

def __str__(self) -> str:
"""Str."""
name = f'"{self.id}"'
Expand All @@ -305,7 +316,7 @@ def __str__(self) -> str:
name += f":{self.dir}"
return name

def __eq__(self, other: "DotLinkEnd") -> bool:
def __eq__(self, other: object) -> bool:
"""Eq."""
if not isinstance(other, DotLinkEnd):
# don't attempt to compare against unrelated types
Expand Down Expand Up @@ -335,12 +346,10 @@ def model_post_init(self, context: typing.Any) -> None: # noqa: ANN401
super().model_post_init(context)

# Add cluster parameters to the theme.
if self.src.is_cluster:
self.theme.ltail = self.src.port.label()
if self.dst.is_cluster:
self.theme.lhead = self.dst.port.label()
self.theme.ltail = self.src.port_label
self.theme.lhead = self.dst.port_label

def __eq__(self, other: "DotLink") -> bool:
def __eq__(self, other: object) -> bool:
"""Eq."""
if not isinstance(other, DotLink):
# don't attempt to compare against unrelated types
Expand All @@ -367,20 +376,20 @@ def __init__(self, file_id: str, title: str, depth: int = 0, title_size: int = 1
self.title = title
self.title_size = title_size
self.rankdir = "LR"
self.graph = {
self.graph: dict[str, str | int] = {
"fontname": DEFAULT_FONT_NAME,
"fontsize": DEFAULT_FONT_SIZE,
"fontcolor": DEFAULT_FONT_COLOR,
"bgcolor": "white",
}
self.node = {
self.node: dict[str, str | int] = {
"penwidth": 0,
"margin": 0,
"fontname": DEFAULT_FONT_NAME,
"fontsize": DEFAULT_FONT_SIZE,
"fontcolor": DEFAULT_FONT_COLOR,
}
self.edge = {
self.edge: dict[str, str | int] = {
"fontname": DEFAULT_FONT_NAME,
"fontsize": DEFAULT_FONT_SIZE,
"fontcolor": "red",
Expand All @@ -401,7 +410,7 @@ def add_table(self, table: DotSignedDoc) -> None:
cluster_name = None
if table.cluster is not None:
cluster_name = table.cluster.name
if cluster_name is not None and cluster_name not in self.clusters:
if cluster_name is not None and cluster_name not in self.clusters and table.cluster is not None:
self.clusters[cluster_name] = table.cluster
if cluster_name not in self.tables:
self.tables[cluster_name] = {}
Expand Down Expand Up @@ -438,9 +447,9 @@ def clustered_tables(self) -> str:
def __str__(self) -> str:
"""Generate the DOT file."""

def defaults(name: str, settings: dict) -> str:
def defaults(name: str, settings: dict[str, str | int]) -> str:
"""Expand the defaults."""
defaults = []
defaults: list[str] = []
for default, value in settings.items():
defaults.append(f'{default}="{value}"')
return f"{name} [{', '.join(defaults)}];"
Expand Down
23 changes: 19 additions & 4 deletions specs/gen_docs/spec/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class DocumentBusinessLogic(BaseModel):
model_config = ConfigDict(extra="forbid")


def empty_string_list() -> list[str]:
"""Get an empty string list."""
return []


class Document(BaseModel):
"""Document Data Definition."""

Expand All @@ -38,8 +43,8 @@ class Document(BaseModel):
versions: list[ChangeLogEntry]

_name: str | None = PrivateAttr(default=None)
_all_refs: list[str] = PrivateAttr(default_factory=list)
_refed_by: list[str] = PrivateAttr(default_factory=list)
_all_refs: list[str] = PrivateAttr(default_factory=empty_string_list)
_refed_by: list[str] = PrivateAttr(default_factory=empty_string_list)

doc_name: str | None = Field(default=None) # Set when wwe get a document

Expand Down Expand Up @@ -74,11 +79,21 @@ def all_references(self) -> list[str]:
return self._all_refs

@property
def name(self) -> list[str]:
def name(self) -> str:
"""Get name of this document."""
return self._name
return self._name if self._name is not None else "Unknown"

@property
def all_docs_referencing(self) -> list[str]:
"""Get name of all documents which reference this document."""
return self._refed_by

@property
def content_type(self) -> str | list[str]:
"""Get document content type."""
content_type = self.headers.get("content type")
if content_type is not None:
content_type = content_type.value
if content_type is None:
content_type = "Undefined"
return content_type
Loading