Skip to content

Commit

Permalink
feat: only add description subject to table
Browse files Browse the repository at this point in the history
Instead of adding the whole description to the table of inputs and outputs only the first line should be added.

Similar to best practice of git commit messages the description would benefit if the description will be split to subject and body.
In the first line the basic information will be placed (subject).
Followed after a blank line the body will follow.

For the action the body will then be available in the usage section only.
This will improve the readability of the table.
  • Loading branch information
fty4 committed Jan 12, 2023
1 parent c1f767d commit cf4b2e0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/sections/update-inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,21 @@ export default function updateInputs(token: string, inputs: Inputs): void {
for (const key of Object.keys(vars)) {
// eslint-disable-next-line security/detect-object-injection
const values = vars[key];

let description = values?.description ?? '';

// Check if only first line should be added (only subject without body)
// eslint-disable-next-line no-useless-escape
const matches = description.match('(.*?)\n\n([\S\s]*)');
if (matches && matches.length >= 2) {
description = matches[1] || description;
}

description = description.trim().replace('\n', '<br />');

const row: string[] = [
`**\`${key.trim()}\`**`,
values?.description?.trim().replace('\n', '<br />') ?? '',
description,
values?.default ? `\`${values.default}\`` : '',
values?.required ? '**true**' : '__false__',
];
Expand Down
14 changes: 13 additions & 1 deletion src/sections/update-outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,21 @@ export default function updateOutputs(token: string, inputs: Inputs): void {
for (const key of Object.keys(vars)) {
// eslint-disable-next-line security/detect-object-injection
const values = vars[key];

let description = values?.description ?? '';

// Check if only first line should be added (only subject without body)
// eslint-disable-next-line no-useless-escape
const matches = description.match('(.*?)\n\n([\S\s]*)');
if (matches && matches.length >= 2) {
description = matches[1] || description;
}

description = description.trim().replace('\n', '<br />');

const row: string[] = [
`\`${key.trim()}\``,
values?.description?.trim().replace('\n', '<br />') ?? '',
description,
];
log.debug(JSON.stringify(row));
markdownArray.push(row);
Expand Down

0 comments on commit cf4b2e0

Please sign in to comment.