Skip to main content

LSA (Linking Software Artifacts) CLI

Version Python Version

The part of LSA project, this CLI tool is used to parse annotations from source code and convert them to entities. Entities are then used to visualize the codebase on the webpage.

Installation

pip install lsa-cli

Usage

lsa-cli <option>

Options:

-p, --path          Parse path
-a, --annotations  Save intermediate annotations model as JSON
-c, --config       Path to the configuration file
-v, --validate     Validate and compare two model files (JSON). Provide two file paths.

Example

The CLI tool parses the source code:

// @lc-entity
// @lc-identifier :Annotation
// @lc-name Annotation
// @lc-description Base class for all annotations.
export interface IAnnotation {
  // @lc-property
  // @lc-name name
  name: string
  // @lc-property
  // @lc-name value
  value: string | null
  // @lc-property
  // @lc-name annotationStartPos
  startPos: number
  // @lc-property
  // @lc-name annotationEndPos
  endPos: number
  // @lc-property
  // @lc-name annotationLine
  lineNumber: number
}

And generates the entities model by lsa-cli -p source-file.ts:

{
  "entities": [
    {
      "name": "Annotation",
      "instances": [
        {
          "from_file": "source-file.ts",
          "identifier": ":Annotation",
          "description": "Base class for all annotations.",
          "properties": [
            {
              "name": "name",
              "description": null
            },
            {
              "name": "value",
              "description": null
            },
            {
              "name": "annotationstartpos",
              "description": null
            },
            {
              "name": "annotationendpos",
              "description": null
            },
            {
              "name": "annotationline",
              "description": null
            }
          ]
        }
      ]
    }
  ]
}
Additionally, you can save the intermediate annotations model as JSON:
{
    "filesAnnotations": [
        {
            "relativeFilePath": "./source-file.ts",
            "annotations": [
                {
                    "name": "entity",
                    "value": null,
                    "lineNumber": 1
                },
                {
                    "name": "identifier",
                    "value": ":Annotation",
                    "lineNumber": 2
                },
                {
                    "name": "name",
                    "value": "Annotation",
                    "lineNumber": 3
                },
        ...

Configuration file

Default configuration file is .lsa-config.json in the current working directory. You can specify the path to the configuration file using the -c option.

lsa-cli -c <path-to-config-file> -p <path-to-source-code>

If the file is not found, default configuration is used:

{
  "markers": {
    "prefix": "@lc-",
    "identifier": "identifier",
    "name": "name",
    "type": "type",
    "description": "description",
    "entity": "entity",
    "property": "property",
    "method": "method",
    "source": "source"
  },
  "parser": {
    "output": {
      "entities": "entities.json",
      "annotations": "annotations.json"
    },
    "exclude": [],
    "extend": {}
  },
}
  • <prefix><marker> - Defines the annotations, where
    • prefix - Prefix for the annotations.
    • markers - Annotation markers (for example, <prefix>entity).
  • parser - Parser settings for the CLI.
    • output - Output files for the CLI.

    • exclude - Paths to exclude from parsing.

      "exclude": ["node_modules", ".git", ".venv"]
      
    • extend - File extensions to extend the parser. Where the key is the extension and the value is the MIME type ( you can see the list of supported MIME types here).

      "extend": {
        "cjs": "application/javascript",
        "mjs": "application/javascript",
        "jsx": "application/javascript"
      }
      

Development

Installation

poetry install

Usage

poetry run lsa-cli

Testing

pytest -c pyproject.toml

Formatting

poetry run poe format-code

Pre-commit

poetry shell
pre-commit install

Metadata

Release files for lsa-cli 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lsa-cli 1.0.0
File Size Uploaded
lsa_cli-1.0.0.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lsa-cli 1.0.0
File Interpreter ABI Platform
lsa_cli-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.0 kB

Release files / lsa_cli-1.0.0.tar.gz

Download URL lsa_cli-1.0.0.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1941ea7b960eb7b1700468cd68a41045d8ec50693779154e246b193f1798754f
BLAKE2b-256 checksum
How to use checksums
00697294eda664268c6b95c8010eb7cf0520ca4bb053524569e62de32034039d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.10 Darwin/24.3.0

Release files / lsa_cli-1.0.0-py3-none-any.whl

Download URL lsa_cli-1.0.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54de7e656aa67c5ae37101b1ddded5410117afc9d6891e683ee4b3f411c88280
BLAKE2b-256 checksum
How to use checksums
17ccae890ec47b483e6900ee50259023c364321a209c0282ea15117eb3df7910
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.10 Darwin/24.3.0

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page