-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathreadme.ts
70 lines (63 loc) · 2.65 KB
/
readme.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. */
import { VdmServiceMetadata } from '../vdm-types';
function title(service: VdmServiceMetadata): string {
return service.npmPackageName || service.speakingModuleName;
}
function serviceReference(
service: VdmServiceMetadata,
s4hanaCloud: boolean
): string {
const ref = service.apiBusinessHubMetadata
? `[${service.speakingModuleName}](${service.apiBusinessHubMetadata.url})`
: service.speakingModuleName;
return s4hanaCloud ? `${ref} of SAP S/4HANA Cloud` : `${ref}`;
}
function communicationScenarioLine(service: VdmServiceMetadata): string[] {
return service.apiBusinessHubMetadata &&
service.apiBusinessHubMetadata.communicationScenario
? [
`This service is part of the following communication scenarios: ${service.apiBusinessHubMetadata.communicationScenario}.`
]
: [];
}
function businessDocumentationLine(service: VdmServiceMetadata): string[] {
return service.apiBusinessHubMetadata &&
service.apiBusinessHubMetadata.businessDocumentationUrl
? [
`You can find additional documentation for this service on [help.sap.com](${service.apiBusinessHubMetadata.businessDocumentationUrl}).`
]
: [];
}
export function helpfulLinksSection(): string[] {
return [
'### Helpful Links',
'',
'- [SAP Cloud SDK](https://github.com/SAP/cloud-sdk)',
'- [Tutorials on developers.sap.com](https://developers.sap.com/tutorial-navigator.html?tag=products:technology-platform/sap-cloud-sdk/sap-cloud-sdk&tag=topic:javascript)',
'- [SAP Cloud SDK on StackOverflow](https://stackoverflow.com/questions/tagged/sap-cloud-sdk?tab=Newest)',
'- [SAP Cloud SDK on answers.sap.com](https://answers.sap.com/tags/73555000100800000895)',
'- [Release notes](https://help.sap.com/doc/2324e9c3b28748a4ae2ad08166d77675/1.0/en-US/js-index.html)',
'- [All versions of this documentation](https://help.sap.com/viewer/product/SAP_CLOUD_SDK/1.0/en-US)',
'- [Product page of the SAP Cloud SDK](https://developers.sap.com/topics/cloud-sdk.html)',
'- [SAP Cloud SDK Continuous Delivery Toolkit](https://github.com/SAP/cloud-s4-sdk-pipeline)',
'- [Example Applications using the SAP Cloud SDK](https://github.com/SAP/cloud-s4-sdk-examples)'
];
}
export function readme(
service: VdmServiceMetadata,
s4hanaCloud = false
): string {
return [
`# ${title(service)}`,
'',
`This package contains the OData VDM for the ${serviceReference(
service,
s4hanaCloud
)}.`,
...communicationScenarioLine(service),
...businessDocumentationLine(service),
'',
...helpfulLinksSection(),
''
].join('\n');
}