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

Update README with generated table #64

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| name | Required | The name of the application repo. Should be the repo-name in the GitHub URL: https://github.com/org/repo-name.|
| name | Required | The name of the application repository. Should be the `repo-name` in the GitHub URL: https://github.com/org/repo-name.|

| kind | Required | The type of the app repo.|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| kind | Required | The type of the app repo.|
| kind | Required | The type of the application repository.|

| 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.|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| title | Optional | Human readable name of the repo to be shown in the UI. Defaults to the name property.|
| title | Optional | Human-readable name of the repository to be shown in the UI. Defaults to the name property.|

| description | Optional | Text describing the application. Inferred from the repo if missing.|
Copy link
Contributor

Choose a reason for hiding this comment

The 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.|
| description | Optional | Text describing the application. If missing, it is inferred from the repository.|

| manifest | Optional | Alternative filename for the west manifest. Defaults to west.yml.|
Copy link
Contributor

Choose a reason for hiding this comment

The 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.|
| manifest | Optional | Alternative file name for the west manifest. Defaults to `west.yml`.|

| license | Optional | The name of the application license, e.g. "Apache 2.0". Inferred from the repo if missing.|
Copy link
Contributor

Choose a reason for hiding this comment

The 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.|
| license | Optional | The name of the application license, for example "Apache 2.0". If missing, it is inferred from the repository.|

| 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.|
Copy link
Contributor

Choose a reason for hiding this comment

The 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.|
| apps | Optional | Glob pattern to find directories containing applications. Applications need a `*.conf` file and the `CMakeLists.txt` file at their root. The glob expressions are used to match directories, so no file pattern is necessary. By default, the nRF Connect for Visual Studio Code extension will assume that there is just a single application sitting at the root of the repository.|

| defaultBranch | Optional | The default git branch that the repository is checked out. Inferred from the repo if missing.|
Copy link
Contributor

Choose a reason for hiding this comment

The 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.|
| defaultBranch | Optional | The default git branch that the repository is checked out at. If missing, it is inferred from the repository.|

| docsUrl | Optional | The URL of the add-on's documentation|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| docsUrl | Optional | The URL of the add-on's documentation|
| docsUrl | Optional | The URL of the add-on's documentation.|

| restricted | Optional | Mark the restricted access to any of the dependencies.|
Copy link
Contributor

Choose a reason for hiding this comment

The 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.|
| restricted | Optional | Check for marking the restricted access to any of the dependencies.|


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.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"copyright": "tsx scripts/copyright.ts",
"generate-index-json": "tsx scripts/generate-index-json.ts",
"validate-index": "tsx scripts/validate-index.ts",
"check-types": "tsc --noEmit"
"check-types": "tsc --noEmit",
"generate-readme": "tsx scripts/readme.ts"
},
"repository": {
"type": "git",
Expand Down
48 changes: 48 additions & 0 deletions scripts/readme.ts
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));
Loading