generated from potassco/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from potassco/14-add-a-glossary-for-predicates
14 add a glossary for predicates
- Loading branch information
Showing
8 changed files
with
96 additions
and
8 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
|
||
from mkdocstrings_handlers.asp.document import Document | ||
from mkdocstrings_handlers.asp.semantics.predicate_documentation import PredicateDocumentation | ||
|
||
|
||
@dataclass | ||
class GlossaryEntry: | ||
""" | ||
A class to represent a glossary entry. | ||
""" | ||
|
||
signature: str | ||
""" The signature of the predicate. """ | ||
description: str | ||
""" The description of the predicate. """ | ||
parameters: dict[str, str] | ||
""" The parameters and their descriptions of the predicate. """ | ||
|
||
|
||
@dataclass | ||
class Glossary: | ||
""" | ||
A class to represent a glossary. | ||
""" | ||
|
||
entries: list[GlossaryEntry] | ||
""" The entries of the glossary. """ | ||
|
||
@staticmethod | ||
def from_document(document: Document) -> Glossary: | ||
""" | ||
Initialize the glossary from an ASP document. | ||
Args: | ||
document: The ASP document. | ||
Returns: | ||
The glossary. | ||
""" | ||
|
||
entries: list[GlossaryEntry] = [] | ||
|
||
for predicate_documentation in document.predicate_documentations: | ||
entry = GlossaryEntry( | ||
signature=predicate_documentation.literal.text, | ||
description=predicate_documentation.description, | ||
parameters=predicate_documentation.parameter_descriptions, | ||
) | ||
entries.append(entry) | ||
|
||
entries.sort(key=lambda x: x.signature) | ||
|
||
return Glossary(entries) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
src/mkdocstrings_handlers/asp/templates/material/dependency_graph.html.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/mkdocstrings_handlers/asp/templates/material/glossary.html.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{% set glossary_block %} | ||
## :material-format-list-bulleted-square: Glossary | ||
|
||
{% for entry in glossary.entries %} | ||
#### <code class="doc-symbol doc-symbol-heading doc-clingo-symbol-predicate"></code> {{ entry.signature }} | ||
|
||
{{ entry.description }} | ||
|
||
{%- if entry.parameters %} | ||
|
||
| Parameter | Description | | ||
| :-------- | :--------------------------------- | | ||
{%- for param, description in entry.parameters.items() %} | ||
| `{{ param }}` | {{ description }} | | ||
{%- endfor %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endset %} | ||
|
||
|
||
{{ glossary_block | convert_markdown(1, "glossary") }} |
4 changes: 4 additions & 0 deletions
4
src/mkdocstrings_handlers/asp/templates/material/separator.html.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{% set separator %} | ||
--------- | ||
{% endset %} | ||
{{ separator | convert_markdown(1, "separator") }} |