Skip to main content

CLI part of Linking Software Artifacts project

Project description

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 <path-to-source-code>

Options:

-a, --annotations  Save intermediate annotations model as JSON
-c, --config       Path to the configuration file

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 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> <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

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

lsa_cli-0.2.8.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

lsa_cli-0.2.8-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file lsa_cli-0.2.8.tar.gz.

File metadata

  • Download URL: lsa_cli-0.2.8.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.10 Darwin/24.3.0

File hashes

Hashes for lsa_cli-0.2.8.tar.gz
Algorithm Hash digest
SHA256 8c349d2d3fdd8f153b98da1a2fbdbf7b1000d16d22d5f058f7abc37bc12ea8b7
MD5 57514472993f120da1fc292fe85d08cb
BLAKE2b-256 b48a92ce053bdbc2eaa6e9f18a2987fb5e45a2a9ca56a33a5a3065bd0ff038d2

See more details on using hashes here.

File details

Details for the file lsa_cli-0.2.8-py3-none-any.whl.

File metadata

  • Download URL: lsa_cli-0.2.8-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.10 Darwin/24.3.0

File hashes

Hashes for lsa_cli-0.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 24743ce72151b6623126f0717d4ecd346b7fa2e9af3d09432fb0dd21dbd4222e
MD5 96ba0bd21b6871423686c505eff6def2
BLAKE2b-256 d749d734ee0944cec0e6c5313719bf5f9ea803d0eb227f72739e3bcb794e88da

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