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

APP-7171: Add README.md to module generate CLI #4731

Merged
merged 3 commits into from
Jan 27, 2025

Conversation

michaellee1019
Copy link
Member

@michaellee1019 michaellee1019 commented Jan 21, 2025

Generates a base README.md for modules created with viam module generate. The template is inspired by our docs readme example. Meta.json is updated to have a relative link to the model level documentation of the readme. I adjusted the template with this feature in mind, attempting to reduce repetitive sentences "to configure a component/service go to..." and "This is a model that implements the ... API" so that the docs embedded in the app are to the point.

Tested the generator locally:
go run cli/viam/main.go module generate
Selected: "my-module-4", "test" namespace, Python, Arm Component, "my-model-4", Use CloudBuild, Register with Viam.

Generated markdown:

# Module my-module-4 

TODO: Provide a description of the purpose of the module and any relevant information.

## Model test:my-module-4:my-model-4

TODO: Provide a description of the model and any relevant information.

### Configuration
The following attribute template can be used to configure this model:

\`\`\`json
{
"attribute_1": <float>,
"attribute_2": <string>
}
\`\`\`

#### Attributes

The following attributes are available for this model:

| Name          | Type   | Inclusion | Description                |
|---------------|--------|-----------|----------------------------|
| `attribute_1` | float  | Required  | Description of attribute 1 |
| `attribute_2` | string | Optional  | Description of attribute 2 |

#### Example Configuration

\`\`\`json
{
  "attribute_1": 1.0,
  "attribute_2": "foo"
}
\`\`\`

### DoCommand

TODO: If your model implements DoCommand, provide an example payload of each command that is supported and the arguments that can be used. If your model does not implement DoCommand, remove this section.

#### Example DoCommand

\`\`\`json
{
  "command_name": {
    "arg1": "foo",
    "arg2": 1
  }
}
\`\`\`

Generated meta.json:

{
  "$schema": "https://dl.viam.dev/module.schema.json",
  "module_id": "test:my-module-4",
  "visibility": "private",
  "url": "",
  "description": "Modular arm component: my-model-4",
  "models": [
    {
      "api": "rdk:component:arm",
      "model": "test:my-module-4:my-model-4",
      "short_description": "Provide a short (100 characters or less) description of this model here",
      "markdown_link": "README.md#model-testmy-module-4my-model-4"
    }
  ],
  "entrypoint": "dist/main",
  "first_run": "",
  "build": {
    "build": "./build.sh",
    "setup": "./setup.sh",
    "path": "dist/archive.tar.gz",
    "arch": [
      "linux/amd64",
      "linux/arm64"
    ]
  }
}

@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label Jan 21, 2025
@michaellee1019
Copy link
Member Author

\`\`\`json

Ignore the backslashes here. Its generated without them. This was the way I could get the full markdown to render as a code block in the PR overview.

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels Jan 21, 2025
@michaellee1019 michaellee1019 requested a review from njooma January 22, 2025 15:05
@njooma njooma merged commit a7916d6 into viamrobotics:main Jan 27, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants