Skip to content

Commit

Permalink
Merge pull request #275 from AsherGlick/generator_arguments
Browse files Browse the repository at this point in the history
Adding arguments to the generator command
  • Loading branch information
AsherGlick authored Feb 5, 2024
2 parents 8b4c71c + 43d8f7d commit 7d7682f
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions xml_converter/generators/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from protobuf_types import get_proto_field_type
from util import capitalize, SchemaType, Document
from generate_cpp import write_cpp_classes, write_attribute
import argparse


XML_ATTRIBUTE_REGEX: Final[str] = "^[A-Za-z]+$"
PROTO_FIELD_REGEX: Final[str] = "^[a-z_.]+$"
Expand Down Expand Up @@ -364,6 +366,14 @@ def generate_auto_docs(self, metadata: Dict[str, SchemaType], content: Dict[str,
# markdown files, and then creating the desired output files.
################################################################################
def main() -> None:
parser = argparse.ArgumentParser(description='Process some flags.')
parser.add_argument('--cpp-nodes', help='Generate the XML Node Classes.', action='store_true')
parser.add_argument('--cpp-attributes', help='Generate the XML Attribute functions.', action='store_true')
parser.add_argument('--documentation', help='Generate the HTML documentation.', action='store_true')
args = parser.parse_args()

generate_all: bool = not args.cpp_nodes and not args.cpp_attributes and not args.documentation

generator = Generator()
markdown_doc_directory = "../doc"

Expand All @@ -372,14 +382,17 @@ def main() -> None:
if os.path.isdir(full_markdown_doc_directory):
generator.load_input_doc(full_markdown_doc_directory)

generator.delete_generated_docs("../web_docs")
generator.write_webdocs("../web_docs/")
if generate_all or args.documentation:
generator.delete_generated_docs("../web_docs")
generator.write_webdocs("../web_docs/")

written_classes = write_cpp_classes("../src/", generator.data)
generator.delete_generated_docs("../src/", skip=written_classes)
if generate_all or args.cpp_nodes:
written_classes = write_cpp_classes("../src/", generator.data)
generator.delete_generated_docs("../src/", skip=written_classes)

written_attributes = write_attribute("../src/attribute", generator.data)
generator.delete_generated_docs("../src/attribute", skip=written_attributes)
if generate_all or args.cpp_attributes:
written_attributes = write_attribute("../src/attribute", generator.data)
generator.delete_generated_docs("../src/attribute", skip=written_attributes)


main()

0 comments on commit 7d7682f

Please sign in to comment.