usd-profiles-nvidia 1.15.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omni/usd_profiles/__init__.py +11 -0
- omni/usd_profiles/codegen/__init__.py +8 -0
- omni/usd_profiles/codegen/__main__.py +11 -0
- omni/usd_profiles/markdown/__init__.py +8 -0
- omni/usd_profiles/model/__init__.py +8 -0
- omni/usd_profiles/parsers/__init__.py +8 -0
- omni/usd_profiles/serialization/__init__.py +8 -0
- omni/usd_profiles/sphinx/__init__.py +11 -0
- omni/usd_profiles/sphinx/directives/__init__.py +8 -0
- omni/usd_profiles/sphinx/ext/__init__.py +7 -0
- omni/usd_profiles/sphinx/ext/directives.py +7 -0
- omni/usd_profiles/sphinx/ext/initialize.py +7 -0
- omni/usd_profiles/sphinx/ext/roles.py +7 -0
- omni/usd_profiles/sphinx/ext/static.py +7 -0
- omni/usd_profiles/sphinx/initialize/__init__.py +8 -0
- omni/usd_profiles/sphinx/roles/__init__.py +8 -0
- omni/usd_profiles/sphinx/static/__init__.py +8 -0
- omni/usd_profiles/store/__init__.py +8 -0
- omni/usd_profiles/toml/__init__.py +8 -0
- usd_profiles_nvidia/__init__.py +6 -0
- usd_profiles_nvidia/__main__.py +3 -0
- usd_profiles_nvidia/codegen/__init__.py +7 -0
- usd_profiles_nvidia/codegen/__main__.py +39 -0
- usd_profiles_nvidia/codegen/_cli.py +61 -0
- usd_profiles_nvidia/codegen/_py_generate.py +135 -0
- usd_profiles_nvidia/codegen/resources/__init__.py +7 -0
- usd_profiles_nvidia/codegen/resources/__init__.py.jinja2 +47 -0
- usd_profiles_nvidia/codegen/resources/_capabilities.py.jinja2 +81 -0
- usd_profiles_nvidia/codegen/resources/_examples.py.jinja2 +74 -0
- usd_profiles_nvidia/codegen/resources/_features.py.jinja2 +45 -0
- usd_profiles_nvidia/codegen/resources/_parameters.py.jinja2 +57 -0
- usd_profiles_nvidia/codegen/resources/_profiles.py.jinja2 +48 -0
- usd_profiles_nvidia/codegen/resources/_protocols.py +88 -0
- usd_profiles_nvidia/codegen/resources/_requirements.py.jinja2 +74 -0
- usd_profiles_nvidia/markdown/__init__.py +25 -0
- usd_profiles_nvidia/markdown/_capabilities.py +92 -0
- usd_profiles_nvidia/markdown/_examples.py +87 -0
- usd_profiles_nvidia/markdown/_features.py +205 -0
- usd_profiles_nvidia/markdown/_model.py +152 -0
- usd_profiles_nvidia/markdown/_parameters.py +155 -0
- usd_profiles_nvidia/markdown/_parser.py +331 -0
- usd_profiles_nvidia/markdown/_profiles.py +93 -0
- usd_profiles_nvidia/markdown/_references.py +109 -0
- usd_profiles_nvidia/markdown/_requirements.py +150 -0
- usd_profiles_nvidia/model/__init__.py +38 -0
- usd_profiles_nvidia/model/_capability.py +35 -0
- usd_profiles_nvidia/model/_compatibility.py +50 -0
- usd_profiles_nvidia/model/_example.py +50 -0
- usd_profiles_nvidia/model/_feature.py +24 -0
- usd_profiles_nvidia/model/_metadata.py +48 -0
- usd_profiles_nvidia/model/_model.py +55 -0
- usd_profiles_nvidia/model/_naming.py +70 -0
- usd_profiles_nvidia/model/_parameter.py +128 -0
- usd_profiles_nvidia/model/_profile.py +20 -0
- usd_profiles_nvidia/model/_requirement.py +41 -0
- usd_profiles_nvidia/model/_specifications.py +36 -0
- usd_profiles_nvidia/model/_tag.py +52 -0
- usd_profiles_nvidia/model/_version.py +129 -0
- usd_profiles_nvidia/parsers/__init__.py +15 -0
- usd_profiles_nvidia/parsers/_capabilities.py +28 -0
- usd_profiles_nvidia/parsers/_features.py +28 -0
- usd_profiles_nvidia/parsers/_profiles.py +34 -0
- usd_profiles_nvidia/parsers/_specifications.py +99 -0
- usd_profiles_nvidia/serialization/__init__.py +8 -0
- usd_profiles_nvidia/serialization/_json_decoder.py +151 -0
- usd_profiles_nvidia/serialization/_json_encoder.py +152 -0
- usd_profiles_nvidia/sphinx/__init__.py +3 -0
- usd_profiles_nvidia/sphinx/directives/__init__.py +8 -0
- usd_profiles_nvidia/sphinx/directives/_common.py +18 -0
- usd_profiles_nvidia/sphinx/directives/_features_table.py +83 -0
- usd_profiles_nvidia/sphinx/directives/_requirements_table.md.j2 +21 -0
- usd_profiles_nvidia/sphinx/directives/_requirements_table.py +89 -0
- usd_profiles_nvidia/sphinx/ext/__init__.py +37 -0
- usd_profiles_nvidia/sphinx/ext/directives.py +31 -0
- usd_profiles_nvidia/sphinx/ext/initialize.py +28 -0
- usd_profiles_nvidia/sphinx/ext/roles.py +39 -0
- usd_profiles_nvidia/sphinx/ext/static.py +28 -0
- usd_profiles_nvidia/sphinx/initialize/__init__.py +8 -0
- usd_profiles_nvidia/sphinx/initialize/_build_jsons.py +56 -0
- usd_profiles_nvidia/sphinx/initialize/_build_specs.py +34 -0
- usd_profiles_nvidia/sphinx/roles/__init__.py +17 -0
- usd_profiles_nvidia/sphinx/roles/_compatibility.py +50 -0
- usd_profiles_nvidia/sphinx/roles/_manual_validation.py +43 -0
- usd_profiles_nvidia/sphinx/roles/_oav_validator_link.py +76 -0
- usd_profiles_nvidia/sphinx/roles/_tags.py +52 -0
- usd_profiles_nvidia/sphinx/roles/_validator_link.py +114 -0
- usd_profiles_nvidia/sphinx/static/__init__.py +8 -0
- usd_profiles_nvidia/sphinx/static/_static.py +38 -0
- usd_profiles_nvidia/sphinx/static/_style.py +25 -0
- usd_profiles_nvidia/store/__init__.py +21 -0
- usd_profiles_nvidia/store/_capabilities.py +51 -0
- usd_profiles_nvidia/store/_examples.py +35 -0
- usd_profiles_nvidia/store/_features.py +45 -0
- usd_profiles_nvidia/store/_keystore.py +137 -0
- usd_profiles_nvidia/store/_parameters.py +69 -0
- usd_profiles_nvidia/store/_profiles.py +29 -0
- usd_profiles_nvidia/store/_requirements.py +31 -0
- usd_profiles_nvidia/store/_specifications.py +46 -0
- usd_profiles_nvidia/toml/__init__.py +10 -0
- usd_profiles_nvidia/toml/_profiles.py +123 -0
- usd_profiles_nvidia-1.15.3.dist-info/METADATA +239 -0
- usd_profiles_nvidia-1.15.3.dist-info/RECORD +104 -0
- usd_profiles_nvidia-1.15.3.dist-info/WHEEL +4 -0
- usd_profiles_nvidia-1.15.3.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from pkgutil import extend_path
|
|
6
|
+
|
|
7
|
+
from usd_profiles_nvidia import __version__
|
|
8
|
+
|
|
9
|
+
__path__ = extend_path(__path__, __name__)
|
|
10
|
+
|
|
11
|
+
__all__ = ["__version__"]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.codegen
|
|
6
|
+
from usd_profiles_nvidia.codegen import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.codegen.__all__
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
from usd_profiles_nvidia.codegen.__main__ import main
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if __name__ == "__main__":
|
|
11
|
+
sys.exit(main())
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.markdown
|
|
6
|
+
from usd_profiles_nvidia.markdown import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.markdown.__all__
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.model
|
|
6
|
+
from usd_profiles_nvidia.model import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.model.__all__
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.parsers
|
|
6
|
+
from usd_profiles_nvidia.parsers import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.parsers.__all__
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.serialization
|
|
6
|
+
from usd_profiles_nvidia.serialization import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.serialization.__all__
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from pkgutil import extend_path
|
|
6
|
+
|
|
7
|
+
import usd_profiles_nvidia.sphinx
|
|
8
|
+
|
|
9
|
+
__path__ = extend_path(__path__, __name__)
|
|
10
|
+
|
|
11
|
+
__all__: list[str] = []
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.sphinx.directives
|
|
6
|
+
from usd_profiles_nvidia.sphinx.directives import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.sphinx.directives.__all__
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.sphinx.initialize
|
|
6
|
+
from usd_profiles_nvidia.sphinx.initialize import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.sphinx.initialize.__all__
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.sphinx.roles
|
|
6
|
+
from usd_profiles_nvidia.sphinx.roles import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.sphinx.roles.__all__
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.sphinx.static
|
|
6
|
+
from usd_profiles_nvidia.sphinx.static import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.sphinx.static.__all__
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.store
|
|
6
|
+
from usd_profiles_nvidia.store import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.store.__all__
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
import usd_profiles_nvidia.toml
|
|
6
|
+
from usd_profiles_nvidia.toml import * # noqa: F403
|
|
7
|
+
|
|
8
|
+
__all__ = usd_profiles_nvidia.toml.__all__
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Command-line interface for code generation.
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
python -m usd_profiles_nvidia.codegen --docs-root docs/ --destination-dir python/ --package-name omni.profiles
|
|
10
|
+
python -m usd_profiles_nvidia.codegen --docs-root docs/ --destination-dir python/ --package-name com.nvidia.simready --reverse-domain com.nvidia.simready
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
import argparse
|
|
16
|
+
import logging
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
from usd_profiles_nvidia.codegen._cli import add_arguments, generate
|
|
20
|
+
|
|
21
|
+
logger = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def main() -> int:
|
|
25
|
+
parser = argparse.ArgumentParser(description="Generate Python from Profiles Markdown files.")
|
|
26
|
+
add_arguments(parser)
|
|
27
|
+
args = parser.parse_args()
|
|
28
|
+
try:
|
|
29
|
+
package_name: str = args.package_name or args.namespace or ""
|
|
30
|
+
reverse_domain: str = args.reverse_domain or ""
|
|
31
|
+
generate(args.docs_root, args.destination_dir, package_name, reverse_domain)
|
|
32
|
+
return 0
|
|
33
|
+
except Exception as e:
|
|
34
|
+
logger.error(f"Error: {e}")
|
|
35
|
+
return 1
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
sys.exit(main())
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from argparse import ArgumentParser
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def add_arguments(parser: ArgumentParser, required: bool = True) -> None:
|
|
11
|
+
"""Add codegen arguments to an argument parser."""
|
|
12
|
+
parser.add_argument(
|
|
13
|
+
"-f",
|
|
14
|
+
"--docs-root",
|
|
15
|
+
dest="docs_root",
|
|
16
|
+
required=required,
|
|
17
|
+
help="Where to find profiles markdown files, i.e. docs/.",
|
|
18
|
+
)
|
|
19
|
+
parser.add_argument(
|
|
20
|
+
"-d",
|
|
21
|
+
"--destination-dir",
|
|
22
|
+
dest="destination_dir",
|
|
23
|
+
required=required,
|
|
24
|
+
help="Destination dir for the generated code, i.e. python/.",
|
|
25
|
+
)
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
"-p",
|
|
28
|
+
"--package-name",
|
|
29
|
+
dest="package_name",
|
|
30
|
+
required=False,
|
|
31
|
+
help="Python package path for generated modules, e.g. omni.profiles.",
|
|
32
|
+
)
|
|
33
|
+
parser.add_argument(
|
|
34
|
+
"-r",
|
|
35
|
+
"--reverse-domain",
|
|
36
|
+
dest="reverse_domain",
|
|
37
|
+
required=False,
|
|
38
|
+
default="",
|
|
39
|
+
help=("Reverse-domain prefix for spec identifiers, e.g. com.nvidia.simready. Empty means legacy behavior."),
|
|
40
|
+
)
|
|
41
|
+
# Deprecated: use --package-name and --reverse-domain instead.
|
|
42
|
+
parser.add_argument(
|
|
43
|
+
"-n",
|
|
44
|
+
"--namespace",
|
|
45
|
+
dest="namespace",
|
|
46
|
+
required=False,
|
|
47
|
+
help="Deprecated: use --package-name and --reverse-domain instead.",
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def generate(docs_root: str, destination_dir: str, package_name: str, reverse_domain: str = "") -> None:
|
|
52
|
+
"""Generate Python code from Profiles Markdown files."""
|
|
53
|
+
from usd_profiles_nvidia.codegen._py_generate import PythonGenerator
|
|
54
|
+
|
|
55
|
+
generator = PythonGenerator(
|
|
56
|
+
docs_root=docs_root,
|
|
57
|
+
destination_dir=destination_dir,
|
|
58
|
+
package_name=package_name,
|
|
59
|
+
reverse_domain=reverse_domain,
|
|
60
|
+
)
|
|
61
|
+
generator.generate()
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import shutil
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from functools import cache
|
|
11
|
+
|
|
12
|
+
from usd_profiles_nvidia.model import Specifications
|
|
13
|
+
from usd_profiles_nvidia.parsers import SpecificationsParser
|
|
14
|
+
from usd_profiles_nvidia.store import SpecificationsStore
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@cache
|
|
18
|
+
def get_environment():
|
|
19
|
+
"""Load the Jinja2 environment.
|
|
20
|
+
|
|
21
|
+
Jinja2 is imported lazily because this module is loaded by the repo tool
|
|
22
|
+
runner whose Python environment may not have jinja2 installed.
|
|
23
|
+
"""
|
|
24
|
+
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
|
25
|
+
|
|
26
|
+
resources_dir: str = os.path.join(os.path.dirname(__file__), "resources")
|
|
27
|
+
loader: FileSystemLoader = FileSystemLoader(resources_dir)
|
|
28
|
+
return Environment(loader=loader, autoescape=select_autoescape(["html", "xml"]))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass(kw_only=True)
|
|
32
|
+
class PythonGenerator:
|
|
33
|
+
"""
|
|
34
|
+
Python code generator for USD Profiles.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
docs_root: Root directory containing capabilities/, profiles/, and features/ subdirectories.
|
|
38
|
+
If provided, capabilities_root, profiles_root, and features_root are derived from it.
|
|
39
|
+
capabilities_root: Directory containing capability files.
|
|
40
|
+
profiles_root: Directory containing profile files.
|
|
41
|
+
features_root: Directory containing feature files.
|
|
42
|
+
destination_dir: Output directory for generated Python code.
|
|
43
|
+
package_name: Python package path for generated modules (e.g. ``"omni.profiles"`` → ``omni/profiles/``).
|
|
44
|
+
reverse_domain: Reverse-domain prefix for spec identifiers (e.g. ``"com.nvidia.simready"``). Empty means legacy behavior.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
docs_root: str | None = None
|
|
48
|
+
capabilities_root: str | None = None
|
|
49
|
+
profiles_root: str | None = None
|
|
50
|
+
features_root: str | None = None
|
|
51
|
+
destination_dir: str
|
|
52
|
+
package_name: str
|
|
53
|
+
reverse_domain: str = ""
|
|
54
|
+
|
|
55
|
+
def __post_init__(self) -> None:
|
|
56
|
+
os.makedirs(self.python_output_dir, exist_ok=True)
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def python_output_dir(self) -> str:
|
|
60
|
+
return os.path.join(self.destination_dir, self.package_name.replace(".", os.path.sep))
|
|
61
|
+
|
|
62
|
+
@classmethod
|
|
63
|
+
def _render_template(cls, template_name: str, **kwargs) -> str:
|
|
64
|
+
"""
|
|
65
|
+
Render a template with the given arguments.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
template_name: Name of the template file (without .jinja2 extension)
|
|
69
|
+
**kwargs: Template variables to pass to the template
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
The rendered template content as a string
|
|
73
|
+
"""
|
|
74
|
+
template = get_environment().get_template(f"{template_name}.jinja2")
|
|
75
|
+
return template.render(**kwargs)
|
|
76
|
+
|
|
77
|
+
def _generate_module(
|
|
78
|
+
self,
|
|
79
|
+
name: str,
|
|
80
|
+
store: SpecificationsStore,
|
|
81
|
+
) -> None:
|
|
82
|
+
destination_file: str = os.path.join(self.python_output_dir, f"{name}.py")
|
|
83
|
+
content = self._render_template(
|
|
84
|
+
f"{name}.py",
|
|
85
|
+
name=name,
|
|
86
|
+
capabilities=store.capabilities,
|
|
87
|
+
profiles=store.profiles,
|
|
88
|
+
requirements=store.requirements,
|
|
89
|
+
features=store.features,
|
|
90
|
+
parameters=store.parameters,
|
|
91
|
+
examples=store.examples,
|
|
92
|
+
)
|
|
93
|
+
with open(destination_file, "w", encoding="utf-8") as destination_fptr:
|
|
94
|
+
destination_fptr.write(content)
|
|
95
|
+
|
|
96
|
+
def _generate_protocols(self) -> None:
|
|
97
|
+
source_file: str = os.path.join(os.path.dirname(__file__), "resources", "_protocols.py")
|
|
98
|
+
with open(source_file, encoding="utf-8") as source_fptr:
|
|
99
|
+
content = source_fptr.read()
|
|
100
|
+
|
|
101
|
+
destination_file: str = os.path.join(self.python_output_dir, "_protocols.py")
|
|
102
|
+
with open(destination_file, "w", encoding="utf-8") as destination_fptr:
|
|
103
|
+
destination_fptr.write(content)
|
|
104
|
+
|
|
105
|
+
def _generate_example_files(self, store: SpecificationsStore) -> None:
|
|
106
|
+
examples_dir: str = os.path.join(self.python_output_dir, "resources", "examples")
|
|
107
|
+
shutil.rmtree(examples_dir, ignore_errors=True)
|
|
108
|
+
os.makedirs(examples_dir, exist_ok=True)
|
|
109
|
+
|
|
110
|
+
for partition, example in store.examples.partition():
|
|
111
|
+
filename: str = example.snippet.filename
|
|
112
|
+
filepath: str = os.path.join(examples_dir, partition, filename)
|
|
113
|
+
os.makedirs(os.path.join(examples_dir, partition), exist_ok=True)
|
|
114
|
+
with open(filepath, "w", encoding="utf-8") as f:
|
|
115
|
+
f.write(example.snippet.content)
|
|
116
|
+
|
|
117
|
+
def generate(self) -> None:
|
|
118
|
+
specifications: Specifications = SpecificationsParser(
|
|
119
|
+
root_dir=self.docs_root,
|
|
120
|
+
capabilities_root=self.capabilities_root,
|
|
121
|
+
profiles_root=self.profiles_root,
|
|
122
|
+
features_root=self.features_root,
|
|
123
|
+
reverse_domain=self.reverse_domain,
|
|
124
|
+
).parse()
|
|
125
|
+
store: SpecificationsStore = SpecificationsStore(specifications)
|
|
126
|
+
|
|
127
|
+
self._generate_module("__init__", store)
|
|
128
|
+
self._generate_module("_parameters", store)
|
|
129
|
+
self._generate_module("_requirements", store)
|
|
130
|
+
self._generate_module("_capabilities", store)
|
|
131
|
+
self._generate_module("_profiles", store)
|
|
132
|
+
self._generate_module("_features", store)
|
|
133
|
+
self._generate_module("_examples", store)
|
|
134
|
+
self._generate_protocols()
|
|
135
|
+
self._generate_example_files(store)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
from ._examples import Examples, Example, ExampleSnippet, ExampleSnippetLanguage, ExampleResult
|
|
5
|
+
from ._parameters import Parameter, Parameters, ParameterType
|
|
6
|
+
from ._requirements import Requirements, Requirement
|
|
7
|
+
from ._capabilities import (
|
|
8
|
+
Capabilities,
|
|
9
|
+
Capability,
|
|
10
|
+
{%- for capability in capabilities %}
|
|
11
|
+
{{ capability.class_name }}Requirements,
|
|
12
|
+
{%- endfor %}
|
|
13
|
+
)
|
|
14
|
+
from ._protocols import (
|
|
15
|
+
RequirementProtocol,
|
|
16
|
+
CapabilityProtocol,
|
|
17
|
+
FeatureProtocol,
|
|
18
|
+
ProfileProtocol
|
|
19
|
+
)
|
|
20
|
+
from ._profiles import Profiles, Profile
|
|
21
|
+
from ._features import Features, Feature
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"Requirements",
|
|
25
|
+
"Requirement",
|
|
26
|
+
"Examples",
|
|
27
|
+
"Example",
|
|
28
|
+
"ExampleSnippet",
|
|
29
|
+
"ExampleSnippetLanguage",
|
|
30
|
+
"ExampleResult",
|
|
31
|
+
"Parameter",
|
|
32
|
+
"ParameterType",
|
|
33
|
+
"Parameters",
|
|
34
|
+
"Capabilities",
|
|
35
|
+
"Capability",
|
|
36
|
+
{%- for capability in capabilities %}
|
|
37
|
+
"{{ capability.class_name }}Requirements",
|
|
38
|
+
{%- endfor %}
|
|
39
|
+
"RequirementProtocol",
|
|
40
|
+
"CapabilityProtocol",
|
|
41
|
+
"FeatureProtocol",
|
|
42
|
+
"ProfileProtocol",
|
|
43
|
+
"Profiles",
|
|
44
|
+
"Profile",
|
|
45
|
+
"Features",
|
|
46
|
+
"Feature",
|
|
47
|
+
]
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from enum import Enum
|
|
7
|
+
|
|
8
|
+
from ._requirements import Requirement, Requirements
|
|
9
|
+
from ._parameters import Parameters
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
{% for capability in capabilities %}
|
|
13
|
+
class {{ capability.class_name }}Requirements(Requirement, Enum):
|
|
14
|
+
"""
|
|
15
|
+
An enumeration of all requirements for the {{ capability.class_name }} capability.
|
|
16
|
+
|
|
17
|
+
.. deprecated:: 0.2.0
|
|
18
|
+
Use :class:`Requirements` instead.
|
|
19
|
+
"""
|
|
20
|
+
{%- for requirement in capability.requirements %}
|
|
21
|
+
{{ requirement.enum_id }} = (
|
|
22
|
+
"{{ requirement.namespaced_id }}",
|
|
23
|
+
"{{ requirement.version or '0.1.0' }}",
|
|
24
|
+
"{{requirement.name or requirement.code}}",
|
|
25
|
+
{{requirement.description | tojson}},
|
|
26
|
+
{{ requirement.metadata.html_path | tojson if requirement.metadata and requirement.metadata.html_path else 'None' }},
|
|
27
|
+
{{ requirement.compatibility.display_name | tojson if requirement.compatibility else 'None' }},
|
|
28
|
+
{%- if requirement.tags %}
|
|
29
|
+
("{{requirement.tags.display_name}}",),
|
|
30
|
+
{%- else %}
|
|
31
|
+
(),
|
|
32
|
+
{%- endif %}
|
|
33
|
+
{%- if requirement.parameters %}
|
|
34
|
+
(
|
|
35
|
+
{%- for param in requirement.parameters %}
|
|
36
|
+
Parameters.{{ param.enum_name }},
|
|
37
|
+
{%- endfor %}
|
|
38
|
+
),
|
|
39
|
+
{%- else %}
|
|
40
|
+
(),
|
|
41
|
+
{%- endif %}
|
|
42
|
+
)
|
|
43
|
+
{% endfor %}
|
|
44
|
+
{% endfor %}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass(frozen=True)
|
|
48
|
+
class Capability:
|
|
49
|
+
"""
|
|
50
|
+
Args:
|
|
51
|
+
id: The id of the capability
|
|
52
|
+
version: The version of the capability
|
|
53
|
+
path: The path to the capability
|
|
54
|
+
requirements: The requirements of the capability
|
|
55
|
+
"""
|
|
56
|
+
id: str
|
|
57
|
+
version: str
|
|
58
|
+
path: str
|
|
59
|
+
requirements: list[Requirement]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class Capabilities(Capability, Enum):
|
|
63
|
+
"""
|
|
64
|
+
An enumeration of all capabilities.
|
|
65
|
+
"""
|
|
66
|
+
{%- for capability in capabilities %}
|
|
67
|
+
{{ capability.enum_id_version }} = (
|
|
68
|
+
"{{ capability.namespaced_id }}",
|
|
69
|
+
"{{ capability.version }}",
|
|
70
|
+
{{ capability.metadata.html_path | tojson if capability.metadata and capability.metadata.html_path else 'None' }},
|
|
71
|
+
[
|
|
72
|
+
{%- for requirement in capability.requirements %}
|
|
73
|
+
Requirements.{{ requirement.enum_id_version }},
|
|
74
|
+
{%- endfor %}
|
|
75
|
+
],
|
|
76
|
+
)
|
|
77
|
+
{%- endfor %}
|
|
78
|
+
# Aliases for latest values
|
|
79
|
+
{%- for capability in capabilities.latest_values() if capability.enum_id != capability.enum_id_version %}
|
|
80
|
+
{{ capability.enum_id }} = {{ capability.enum_id_version }}
|
|
81
|
+
{%- endfor %}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from enum import Enum
|
|
7
|
+
from functools import cached_property
|
|
8
|
+
from importlib.resources import files
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ExampleResult(str, Enum):
|
|
12
|
+
"""
|
|
13
|
+
Args:
|
|
14
|
+
SUCCESS: The example succeeded.
|
|
15
|
+
FAILURE: The example failed.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
SUCCESS = "success"
|
|
19
|
+
FAILURE = "failure"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ExampleSnippetLanguage(str, Enum):
|
|
23
|
+
"""
|
|
24
|
+
Args:
|
|
25
|
+
PYTHON: The example snippet is in Python.
|
|
26
|
+
USD: The example snippet is in USD.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
PYTHON = "python"
|
|
30
|
+
USD = "usd"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True)
|
|
34
|
+
class ExampleSnippet:
|
|
35
|
+
"""
|
|
36
|
+
Args:
|
|
37
|
+
language: The language of the example snippet.
|
|
38
|
+
content: The content of the example snippet (lazy-loaded from file).
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
language: ExampleSnippetLanguage
|
|
42
|
+
path: str
|
|
43
|
+
|
|
44
|
+
@cached_property
|
|
45
|
+
def content(self) -> str:
|
|
46
|
+
resource_files = files(__package__) / "resources" / "examples" / self.path
|
|
47
|
+
return resource_files.read_text(encoding='utf-8')
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@dataclass(frozen=True)
|
|
51
|
+
class Example:
|
|
52
|
+
"""
|
|
53
|
+
Args:
|
|
54
|
+
snippet: The snippet of code in a specific language.
|
|
55
|
+
name: The name of the example.
|
|
56
|
+
result: The result of the example.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
snippet: ExampleSnippet
|
|
60
|
+
display_name: str
|
|
61
|
+
result: ExampleResult
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class Examples(Example, Enum):
|
|
65
|
+
"""
|
|
66
|
+
An enumeration of all examples.
|
|
67
|
+
"""
|
|
68
|
+
{%- for partition, example in examples.partition() %}
|
|
69
|
+
{{ example.enum_name }} = (
|
|
70
|
+
ExampleSnippet(language={{ example.snippet.language }}, path="{{ partition }}/{{ example.snippet.filename }}"),
|
|
71
|
+
"{{ example.name }}",
|
|
72
|
+
{{ example.result }},
|
|
73
|
+
)
|
|
74
|
+
{%- endfor %}
|