Skip to main content

uuts library for Time Series Metamodel documentation generation

Project description

uuts

the library to generate documentation for time series metamodel.

Installation Windows (one-liner)

  1. Create an emtpy directory and name it for example "uuts"
  2. Press the following two keys on the keyboard WIN + R, type "cmd" and navigate to the new directory using "cd C:...\uuts"
  3. Type the following command and execute it:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" && set Path=C:\Users\User\.local\bin;%Path% && uv init && uv add uuts && uv sync --upgrade && uv run python -c "import uuts.init"

Sometimes it is necessary to restart the terminal and run the command above again to make the changes take effect.

Installation Windows (using init.bat)

  1. Create an emtpy directory and name it for example "uuts"
  2. Create an empty file in the newly created "uuts" directory. Name it "win_01_init.bat".
  3. Copy the following text into the file "win_01_init.bat":
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
set Path=C:\Users\User\.local\bin;%Path% 
uv init 
uv add uuts
uv lock --upgrade
pause
  1. Execute a file by double clicking on it

Installation Linux, macOS

  1. Create an emtpy directory and name it for example "uuts"
  2. Open newly created directory
  3. Run the following commands:
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "or use wget if there is a problem with curl"
wget -qO- https://astral.sh/uv/install.sh | sh
uv init 
uv add uuts

How to use the uuts

Create a new file in the "uuts" directory. Name it "run.bat" or "run.sh". Copy the following text into the file "run.bat" or "run.sh":

uv run main.py --action "generateDocumentation" --input "C:\git\cams\Toolkit\metamodel\deploy\etrm" --output "./" --language "cs"

Create a main.py file with following code:

from uuts import generateDocumentation
import uuts.documentation as tsdoc
from pathlib import Path
import sys
import argparse


class MyParser(argparse.ArgumentParser):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs) 
    
    def error(self, message):
        self.print_help(sys.stderr)
        self.exit(2, '%s: error: %s\n' % (self.prog, message))

    def _check_directory_exists(self, value: str) -> bool:
        """
        Validates and returns the absolute path to the output directory.
        """
        path = Path(value.rstrip("/\\"))
        path = path.resolve()
        return path.exists()

    def _input_str(self, value: str) -> str:
        """
        Validates and returns the absolute path to the input directory.
        """
        if self._check_directory_exists(value):
            return str(value)
        else:
            raise argparse.ArgumentTypeError(f"Input directory {value} does not exist")


    def _output_str(self, value: str) -> str:
        """
        Validates and returns the absolute path to the output directory.
        """
        if self.args.action == "generateDocumentation":
            if self._check_directory_exists(value):
                return str(value)
            else:
                raise argparse.ArgumentTypeError(f"Output directory {value} does not exist")
        else:
            raise argparse.ArgumentTypeError(f"--output is not required for action {self.args.action} but was provided")
        
    def validate_args(self, args):
        """
        Validates the command-line arguments.
        """
        if args.action == "generateDocumentation":
            if not self._check_directory_exists(args.input):
                raise argparse.ArgumentTypeError(f"Input directory {args.input} does not exist")
            if not self._check_directory_exists(args.output):
                raise argparse.ArgumentTypeError(f"Output directory {args.output} does not exist")
        else:
            raise argparse.ArgumentTypeError(f"Unknown action {args.action}. Action was not implemented.")
        

def main():
    """
    Main function to generate documentation for the Time Series Metamodel.
    Parses command-line arguments and initiates the documentation generation process.
    """
    parser = MyParser(
        description='Documentation generator for Time Series Metamodel.',
        epilog="Example: uv run generatedoc.py --action \"generateDocumentation\" --input \"absolute_path_to_metamodel.zip\" "
               "--output \"absolute_path_to_output_directory\" --language \"cs\""
    )
    parser.add_argument('--action', type=str, required=True, help='Action to perform. Either "generateDocumentation" to generate documentation or "analyzeImpact" to run analyzeImpact of the metamodel or "analyzeImpactAndDeploy" to run analyzeImpact and deploy procedure')
    parser.add_argument('--input', type=str, required=True, help='Path to the metamodel zip file or metamodel directory.')
    parser.add_argument('--output', type=str, required=False, default='./', help='Path to the output documentation directory. (default: "./")')
    parser.add_argument('--language', type=str, required=False, default='en', help='Language code for the documentation (default: "en").')
    parser.add_argument('--pages', type=str, required=False, default='', help='List of urls of pages used in case there '
                         'are so many tsdefinitions that the documentation needs to be split into '
                         'multiple pages. (default: "") Example: "book/page?code=4532154,book/page?code=56476")')
    # Parse arguments
    args = parser.parse_args(sys.argv[1:])
    parser.validate_args(args)
    page_urls = []
    if args.pages:
        page_urls = args.pages.split(',')
    # Set up paths
    metamodel_path = Path(args.input)
    output_path = Path(args.output.rstrip("/\\"))
    print(f'Generating documentation from "{str(metamodel_path.resolve())}" '
          f'to "{str(output_path.resolve())}" in language "{args.language}"')
    # Generate documentation
    documentation = tsdoc.Documentation(metamodel_path, output_path)
    documentation.generate_documentation(language=args.language, page_urls=page_urls)
    print(f'\nOK - documentation successfully generated\nSee "{str(output_path.resolve())}"\n')

if __name__ == "__main__":
    main()
    exit(0)

Run the file by double clicking on it or by running it in the terminal.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uuts-1.0.28.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uuts-1.0.28-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file uuts-1.0.28.tar.gz.

File metadata

  • Download URL: uuts-1.0.28.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for uuts-1.0.28.tar.gz
Algorithm Hash digest
SHA256 22f5e9ff3de289ae3181e55c0e2f81031e6114de41ee42ef460fcc6d36d9b58d
MD5 b40617b5b8d0b5dfe9a1e21d0378360c
BLAKE2b-256 c3991a6636dcebf72eceecd845521c5e4012f97f655dc10e11b90a829354ffda

See more details on using hashes here.

File details

Details for the file uuts-1.0.28-py3-none-any.whl.

File metadata

  • Download URL: uuts-1.0.28-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for uuts-1.0.28-py3-none-any.whl
Algorithm Hash digest
SHA256 cbdad0689d7274d11617f4567b18569974da94ba262d838f76a3fa9afed5808f
MD5 a4a1387b4a7015c62745fad304fb4e57
BLAKE2b-256 cb8bfa8e971185c9d1146fd7f09744d25d3b359f82dc96f34fb3c2b40403a216

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page