Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] KCL doc tool: extract, generate document of KCL packages #139

Closed
amyXia1994 opened this issue Aug 18, 2023 · 1 comment
Closed
Assignees
Labels

Comments

@amyXia1994
Copy link
Contributor

amyXia1994 commented Aug 18, 2023

Feature Request

Users and Typical Scenarios

  • Document creation & maintenance: Platform SRE
  • Document review & consumption: Application SRE and developer

User story and Workflow

Command Line Interface

The kcl-doc command extracts and renders documentation files of KCL packages. It will provider 2 sub commands: generate, start:

kcl-doc:

# kcl-doc command
kcl-doc -h

Usage: [--version] [--help] <command> [<args>]
Available commands are:
                the generate command is run by default
    generate    generates documents from code and examples
    start       starts a document website locally

arguments:
    --version                        show version of this kcl-doc command line tool
    --help                           show this information

kcl-doc generate:

# kcl-doc generate command
kcl-doc generate -h
generates documents from code and examples
    --schema-path <ARG>              Relative or absolute file path to the KCL package root
                                     when running kcl-doc command from outside of the KCL package root directory.
                                     If not specified, docs of all the KCL models under the work directory will be generated.
    --ignore-deprecated <ARG>        Do not generate documentation for deprecated schemas                                      (default: "false")
    --format <ARG>                   The document format to generate. Supported values: markdown, html, openapi                                                 (default: "markdown")
    --target <ARG>                   The target directory to store the generated document files.                               (default: "")
                                     If not specified, the current work directory will be used.
                                     A docs/ folder will be created under the target directory

kcl-doc start:

# kcl-doc start command
kcl-doc start
starts a document website locally

Spec of KCL Package and Schema Docs

the KCL doc spec is detailed defined in: #156

Integrate with IDE

doc highlight

Attribute names, types and descriptions in docstring can be highlighted at the semantic level to improve docstring readability. Here's a good example:

image

Hover to see docs

When the cursor hovers over the schema name and Attribute name, the document is displayed:

package info
---
schema description
---
**attribute**: type
description
---
\`\`\`
Example
\`\`\`

Here's a good example:

image

Document preview

In the schema file toolbar, click the preview button to expand the preview format of the document. The preview view in Markdown format is loaded by default. Here's a good example:

image

Auto-Completion in writing docstring

When a docstring is added to the model, the scaffolding code in docstring format is automatically generated, and the <> is a placeholder to be filled by the user:

<schema_description>

Attributes
----------
attr_name: <attribute_description>

Examples
--------
<example_code>

When editing docstring, automatically complete the Attributes document in docstring format, as well as the Attributes/Examples chapter title, etc. :

  1. Auto-complete attribute names: Attributes, triggered by newlines/English characters
  2. Automatically completes Attribues & Examples Chapter title: In the first line of the chapter, it is triggered by the prefix of the newline/chapter name

Here's a demo:

docstring_completion

Diagnose and error reporting

Model/attributes for a. missing documents; b. The document contains undefined attributes; c. If the document content does not match the attribute declaration, mark the error message and provide quick repair actions.
todo: The contents and quick repair actions of each type of error prompt need to be detailed and discussed in the design of the error prompt function.

Auto-Completion in writing config

When assigning a configuration value, the assignment expression, including schema expr and value of attribute entry, completes the code snippet, and displays the snippet across multiple lines using inline completion. The snippets in samples/docstring-examples can be used as a source of completed code snippets.

Here's a demo:

example_completion

Go to definition & reference

Jump from the attribute name in the docstring to the attribute definition and vice versa.
A good example:

goto

Integrate with Github/Gitlab Pipeline

Integrated CICD pipeline in the model library

  1. Document validation: A subset of the functionality of kcl-lint action
  2. Document synchronization: Generate documents and synchronize them to github page; Synchronize data to the specified webhook

Integrate with Kpm Registry

  • kpm package doc auto sync: CICD pipeline
@amyXia1994
Copy link
Contributor Author

amyXia1994 commented Sep 12, 2023

@amyXia1994 amyXia1994 changed the title WIP [Feature] KCL doc tool: extract, generate document of KCL packages [Feature] KCL doc tool: extract, generate document of KCL packages Sep 12, 2023
@Peefy Peefy added this to KCL 2023 Sep 18, 2023
@Peefy Peefy moved this to Backlog in KCL 2023 Sep 18, 2023
@Peefy Peefy added the tool label Oct 9, 2023
@Peefy Peefy closed this as completed Oct 9, 2023
@github-project-automation github-project-automation bot moved this from Backlog to v0.7.0 Release Done in KCL 2023 Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: v0.7.0 Release Done
Development

No branches or pull requests

2 participants