Skip to content

Commit bc866b6

Browse files
committed
feat: render picklist values in doc template
1 parent cb2dccb commit bc866b6

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

src/core/markdown/__test__/generating-custom-object-docs.spec.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { extendExpect } from './expect-extensions';
22
import {
33
customField,
4+
customFieldPickListValues,
45
customObjectGenerator,
56
generateDocs,
67
unparsedFieldBundleFromRawString,
@@ -46,7 +47,6 @@ describe('Generates Custom Object documentation', () => {
4647
expect(result).documentationBundleHasLength(1);
4748
assertEither(result, (data) => expect(data).firstDocContains('`TestObject__c`'));
4849
});
49-
5050
it('displays the Fields heading if fields are present', async () => {
5151
const customObjectBundle = unparsedObjectBundleFromRawString({
5252
rawContent: customObjectGenerator(),
@@ -63,6 +63,24 @@ describe('Generates Custom Object documentation', () => {
6363
expect(result).documentationBundleHasLength(1);
6464
assertEither(result, (data) => expect(data).firstDocContains('## Fields'));
6565
});
66+
it('displays the pick list values name', async () => {
67+
const customObjectBundle = unparsedObjectBundleFromRawString({
68+
rawContent: customObjectGenerator(),
69+
filePath: 'src/object/TestObject__c.object-meta.xml',
70+
});
71+
72+
const customFieldBundle = unparsedFieldBundleFromRawString({
73+
rawContent: customFieldPickListValues,
74+
filePath: 'src/object/TestField__c.field-meta.xml',
75+
parentName: 'TestObject__c',
76+
});
77+
78+
const result = await generateDocs([customObjectBundle, customFieldBundle])();
79+
expect(result).documentationBundleHasLength(1);
80+
assertEither(result, (data) => expect(data).firstDocContains('* Staging'));
81+
assertEither(result, (data) => expect(data).firstDocContains('* Active'));
82+
assertEither(result, (data) => expect(data).firstDocContains('* Inactive'));
83+
});
6684

6785
it('does not display the Fields heading if no fields are present', async () => {
6886
const input = unparsedObjectBundleFromRawString({

src/core/markdown/__test__/test-helpers.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,36 @@ export const customField = `
8484
<type>Url</type>
8585
<description>A URL that points to a photo</description>
8686
</CustomField>`;
87+
88+
export const customFieldPickListValues = `
89+
<?xml version="1.0" encoding="UTF-8"?>
90+
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
91+
<fullName>Status__c</fullName>
92+
<externalId>false</externalId>
93+
<label>Status</label>
94+
<required>true</required>
95+
<trackFeedHistory>false</trackFeedHistory>
96+
<description>Status</description>
97+
<type>Picklist</type>
98+
<valueSet>
99+
<restricted>true</restricted>
100+
<valueSetDefinition>
101+
<sorted>false</sorted>
102+
<value>
103+
<fullName>Staging</fullName>
104+
<default>false</default>
105+
<label>Staging</label>
106+
</value>
107+
<value>
108+
<fullName>Active</fullName>
109+
<default>false</default>
110+
<label>Active</label>
111+
</value>
112+
<value>
113+
<fullName>Inactive</fullName>
114+
<default>false</default>
115+
<label>Inactive</label>
116+
</value>
117+
</valueSetDefinition>
118+
</valueSet>
119+
</CustomField>`;

src/core/markdown/adapters/type-to-renderable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ function fieldMetadataToRenderable(
281281
description: field.description ? [field.description] : [],
282282
apiName: getApiName(field.name, config),
283283
fieldType: field.type,
284+
pickListValues: field.pickListValues
284285
};
285286
}
286287

src/core/markdown/templates/custom-object-template.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export const customObjectTemplate = `
2323
**Type**
2424
2525
*{{fieldType}}*
26+
{{#each pickListValues}}
27+
* {{this}}
28+
{{/each}}
2629
{{/if}}
2730
2831
{{#unless @last}}---{{/unless}}

src/core/renderables/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ export type RenderableCustomField = {
189189
heading: string;
190190
apiName: string;
191191
description: RenderableContent[];
192+
pickListValues: string[];
192193
type: 'field';
193194
fieldType?: string | null;
194195
};

0 commit comments

Comments
 (0)