Skip to content

Commit

Permalink
generated Docs action - Add Header (deprecated & legacyIds info) (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
samruddhikhandale authored Jan 4, 2023
1 parent 71918a2 commit 977880a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/generateDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as path from 'path';
import { getGitHubMetadata } from './utils';

const FEATURES_README_TEMPLATE = `
#{Header}
# #{Name}
#{Description}
Expand Down Expand Up @@ -120,6 +121,23 @@ async function _generateDocumentation(basePath: string, readmeTemplate: string,
urlToConfig = `https://github.com/${srcInfo.owner}/${srcInfo.repo}/blob/main/${basePathTrimmed}/${f}/${metadataFile}`;
}

let header = '';
const isDeprecated = parsedJson?.deprecated;
const hasLegacyIds = parsedJson?.legacyIds && parsedJson?.legacyIds.length > 0;

if (isDeprecated || hasLegacyIds) {
header = '### **IMPORTANT NOTE**\n';

if (isDeprecated) {
header += `- **This Feature is deprecated, and will no longer receive any further updates/support.**\n`;
}

if (hasLegacyIds) {
const formattedLegacyIds = parsedJson.legacyIds.map((legacyId: string) => `'${legacyId}'`);
header += `- **Ids used to publish this Feature in the past - ${formattedLegacyIds.join(', ')}**\n`;
}
}

const newReadme = readmeTemplate
// Templates & Features
.replace('#{Id}', parsedJson.id)
Expand All @@ -131,7 +149,8 @@ async function _generateDocumentation(basePath: string, readmeTemplate: string,
// Features Only
.replace('#{Registry}', ociRegistry)
.replace('#{Namespace}', namespace)
.replace('#{Version}', version);
.replace('#{Version}', version)
.replace('#{Header}', header);

// Remove previous readme
if (fs.existsSync(readmePath)) {
Expand Down

0 comments on commit 977880a

Please sign in to comment.