-
Notifications
You must be signed in to change notification settings - Fork 6
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
Update README with generated table #64
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -37,18 +37,20 @@ To generate an `index.json` template file: | |||||
To create an `index.json` of your own, you can either [generate a template](#generating-indexjson) or create a custom file from scratch. | ||||||
Your custom JSON file must include the following information: | ||||||
|
||||||
* Information about your account or organization (`name` and `description`). | ||||||
* Inside the `apps` array, an entry for each add-on you want to be shown in the index: | ||||||
|
||||||
* `name` must match the add-on's GitHub repository in your account. | ||||||
* `title` is the human-readable name of the repository. | ||||||
* `description` is the short description of the add-on. | ||||||
* `manifest` is the alternative name of the west manifest. Defaults to `west.yml`. | ||||||
* `kind` is the type of add-on. | ||||||
* `tags` are the tags that will be used to categorize the add-on. | ||||||
* `license` is the license type name. | ||||||
* `apps` is the global pattern to find directories containing add-ons. | ||||||
* `releases` are the add-on versions. | ||||||
| Property | Requirement | Description | | ||||||
| -------- | ------------ | ----------- | | ||||||
| name | Required | The name of the application repo. Should be the repo-name in the GitHub URL: https://github.com/org/repo-name.| | ||||||
| kind | Required | The type of the app repo.| | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| tags | Required | An array of tags describing the application.| | ||||||
| releases | Required | The collection of project`s releases.| | ||||||
| title | Optional | Human readable name of the repo to be shown in the UI. Defaults to the name property.| | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| description | Optional | Text describing the application. Inferred from the repo if missing.| | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| manifest | Optional | Alternative filename for the west manifest. Defaults to west.yml.| | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| license | Optional | The name of the application license, e.g. "Apache 2.0". Inferred from the repo if missing.| | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| apps | Optional | Glob pattern to find directories containing applications.Applications need a *.conf file and a CMakeLists.txt file at their root. The glob expressions are used to match directories, so no file pattern is necessary.By default, the VS Code extension will assume that there's just a single application sitting at the root of the repo.| | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| defaultBranch | Optional | The default git branch that the repository is checked out. Inferred from the repo if missing.| | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| docsUrl | Optional | The URL of the add-on's documentation| | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| restricted | Optional | Mark the restricted access to any of the dependencies.| | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Most of the information provided in these entries will be displayed on the add-on index page. | ||||||
For more information about each entry, see `appMetadataSchema` in the `resources/schema.json` file. | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* Copyright (c) 2025 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
/** | ||
* This script creates a markdown table based on the index schema the contributors need to follow. | ||
* It outputs the table to the console. | ||
*/ | ||
|
||
import { appMetadataSchema as appSchema } from "../site/src/schema"; | ||
import { JSONSchema } from "json-schema-to-ts"; | ||
|
||
function generatePropertiesDescription(schema: JSONSchema, requiredOnly: boolean = false): Array<{name: string, description: string}> { | ||
const required = Object.entries(schema).find((k) => k[0] === 'required')?.[1]; | ||
if (!required && requiredOnly) { | ||
return [] | ||
} | ||
|
||
const props = Object.entries(schema).find((k) => k[0] === 'properties')?.[1]; | ||
const desc: Array<{name: string, description: string}> = []; | ||
|
||
Object.keys(props).forEach((prop) => { | ||
const isRequired = required.includes(prop); | ||
|
||
if ((requiredOnly && isRequired) || (!requiredOnly && !isRequired)) { | ||
desc.push({ name: prop, description: props[prop]?.description.replaceAll('\n', '') }); | ||
} | ||
}); | ||
|
||
return desc; | ||
} | ||
|
||
function generateMarkdown(schema: JSONSchema): string { | ||
const mandatory = generatePropertiesDescription(schema, true); | ||
const optional = generatePropertiesDescription(schema); | ||
const header = ['| Property | Requirement | Description |', | ||
'| -------- | ------------ | ----------- |' | ||
].join('\n'); | ||
|
||
const content = | ||
[...mandatory.map((property) => {return `| ${property.name} | Required | ${property.description}|`}), | ||
...optional.map((property) => {return `| ${property.name} | Optional | ${property.description}|`})]; | ||
|
||
return [header, ...content].join('\n'); | ||
} | ||
|
||
console.log(generateMarkdown(appSchema)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.