Skip to content

Commit 1c14bed

Browse files
authored
Update Readme to include information on how to add a "getting-started" to the API catalog (#214)
* Move content under resources * Adding how-to add a getting started section * Fix img uri * Update README.md
1 parent 822e74f commit 1c14bed

File tree

7 files changed

+86
-6
lines changed

7 files changed

+86
-6
lines changed

README.md

+27
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,33 @@ To be more bot-friendly we pre-render the whole site to allow it to be crawled.
9898
You can run trigger a local run by building the site `npm run build` and then running `npm run prerender`. The results of the pre-rendering are written in
9999
[build/pre-rendered](./build/pre-rendered)
100100

101+
## Adding external content
102+
103+
Details from each API is extracted from its openapi file to show in the API catalog. Sometimes this is not enough.
104+
We provide an option to add additional sections. Each section is specified as a [markdown file](https://www.markdownguide.org/basic-syntax/)
105+
and has a specific place on the API catalog.
106+
107+
The content is rendered in the API catalog using the same look and feel. Here is an example of a
108+
[getting started](./examples/getting-started.md) section:
109+
110+
![Getting started sample](./examples/getting-started.png?raw=true "Getting started sample")
111+
112+
### Adding a section
113+
114+
A markdown file needs to be added to [./packages/discovery/resources/content](./packages/discovery/resources/content)
115+
under the group-id and api-id using one of the [supported sections](#supported-sections) filenames.
116+
117+
e.g. to add Getting started section for Notifications we need to create the following file:
118+
[./packages/discovery/resources/content/hcc-insights/notifications/getting-started.md](./packages/discovery/resources/content/hcc-insights/notifications/getting-started.md)
119+
120+
This file will be used when regenerating the API files to add a new section on the API catalog.
121+
122+
### Supported sections
123+
124+
This is a list of the support sections, followed by the required file name.
125+
126+
- Getting started: `getting-started.md`
127+
101128
## Releasing to Production
102129

103130
We use GitLab tags for deployment to Production. Follow these steps:

examples/getting-started.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
## Ostendit una oculos
2+
3+
*Lorem markdownum solus*. Coniuge hospita ignarus, rostrisque respondit geminas
4+
Corintho pluma.
5+
6+
key = downPmuParity / e - -3 + monitor_dimm_bitmap + page * 1 +
7+
card_dot_serial;
8+
var byte_isp = 5;
9+
var logic = crossplatform(iscsi.olapWebsiteAccess(tokenLeak, -2), 407696);
10+
surface.disk(upnp_leaf_reimage);
11+
12+
## Acti membra custodia tantaque iuveni Meleagron terrae
13+
14+
*Virum* femineae in [imago in desideret](http://sesimul.io/nempe-acu.php) dona,
15+
sub arma quis annum arbore. Et aderant Editus, erubuit dolore lacertos prudens
16+
pedum: atrox inque! Mallem ait cuius, Prospicientis Ammon.
17+
18+
## Anno fert miserrima mortis post cista
19+
20+
Tenebat spes fontibus sceptra; Cythereia Nocte trepidumque mihi ramosque ego
21+
epulis, modo. Atque non sibi clam pudore, tenues somnus murmure [adlevat
22+
ululavit](http://sisacro.com/auditurumacuto).
23+
24+
- Mira limite
25+
- Progenitore aut
26+
- Formasque stillabant terras
27+
28+
## Simus insignia exuit saturos
29+
30+
Matertera ardent; mox quo inminet brevi, passuque ante poscenti perfida coeunt
31+
vel et iuncta sanguine tergum. Volentem superi in quid alto quoque coniugium
32+
fata *dubitanti illa* hospes ubi quanto animos, esse. Avorum Serpens undae et
33+
taurum nubibus est exilio: [coniugis censu](http://obliquo.net/).
34+
35+
## Aethon iactum si foret viro
36+
37+
Luco mihi, fata ire auras, hic cuius ille, minus oraque? Considerat parva
38+
spectabilis haec!
39+
40+
> Suis mecum [vehebat et et](http://www.cum-abest.org/) quoque, virique
41+
> parantem. Ipsaque velat, signaverat non quidem tempore adventare partes
42+
> Cecropidae domum; minimum. Pignus auxiliumque colla avari Iason piget plura
43+
> auctor sedes quod plura. *Materno* fuit vidit amat vidit rumpe est iam optatae
44+
> Eurytus [Asterien](http://tum.io/); praestantes decor, enim quo rogata
45+
> differtis vidit?
46+
47+
Atque ab eligit arma caede, in ad aures, ait humo cibos Cecropios sucos ductae.
48+
Non sacra qua mente viriles classe tu signa venientis domus et o passus patulas
49+
cauda non; gravis. Exemit luctatur neque, *peragant* ignes quaesierat aglauros
50+
et nigrum amorem.
51+
52+
Generated from: https://github.com/jaspervdj/lorem-markdownum/

examples/getting-started.png

157 KB
Loading

packages/transform/src/constants.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const RESOURCES_DIR = ['resources'];
2+
export const CONTENT_DIR = [...RESOURCES_DIR, 'content'];
3+
export const OPENAPI_DIR = [...RESOURCES_DIR, 'api'];

packages/transform/src/documentation.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@ import {existsSync, readdirSync, readFileSync} from "fs";
33
import path from "path";
44
import snakeCase from 'lodash.snakecase';
55
import {ExtraAPIContent} from "@apidocs/common";
6+
import {CONTENT_DIR} from "./constants";
67

78
export type DocumentationMap = {
89
[documentationType: string]: string;
910
}
1011

1112
const acceptedExtensions: ReadonlyArray<string> = [ '.md' ];
1213

13-
const CONTENT_DIR = 'content';
14-
15-
1614
const isDocumentation = (maybeDocumentation: string): boolean => {
1715
return (Object.values(ExtraAPIContent) as ReadonlyArray<string>).includes(maybeDocumentation);
1816
}
1917

2018
export const getDocumentationContents = (group: Group, app: App, baseDir: string): DocumentationMap => {
2119
const pathToContent = path.resolve(
2220
baseDir,
23-
CONTENT_DIR,
21+
...CONTENT_DIR,
2422
group.id,
2523
app.id
2624
);

packages/transform/src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {OpenAPI, OpenAPIV3} from "openapi-types";
1313
import sortedJsonStringify from 'sorted-json-stringify';
1414
import {getDocumentationContents} from "./documentation";
1515
import {APIContent} from "@apidocs/common";
16+
import {OPENAPI_DIR} from "./constants";
1617

1718
interface Options {
1819
inputDir: string;
@@ -59,8 +60,7 @@ const getOpenAPIContent = async (discoveryPath: string, app: App, group: string,
5960
if (app.useLocalFile) {
6061
return readFileSync(path.resolve(
6162
discoveryPath,
62-
'resources',
63-
'api',
63+
...OPENAPI_DIR,
6464
group,
6565
app.id,
6666
'openapi.json'

0 commit comments

Comments
 (0)