Skip to content

Commit 748eaf1

Browse files
Add support for inline help text from fields
Add flag to signal output of inlineHelpText metadata from Salesforce fields. Update the markdown section of the readme to include the flag details.
1 parent 73b78bf commit 748eaf1

File tree

13 files changed

+45
-1
lines changed

13 files changed

+45
-1
lines changed

examples/markdown/force-app/objects/Event__c/fields/Social_Security_Number__c.field-meta.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<fullName>Social_Security_Number__c</fullName>
44
<externalId>false</externalId>
55
<label>Social Security Number</label>
6+
<inlineHelpText>You indicated the approval for storage of your social security number.</inlineHelpText>
67
<description>Used to store the U.S. social security number in 9 digit format.</description>
78
<length>9</length>
89
<trackTrending>false</trackTrending>

src/cli/commands/markdown.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,9 @@ export const markdownOptions: Record<keyof CliConfigurableMarkdownConfig, Option
7676
type: 'boolean',
7777
describe: 'Whether to include the compliance category and security classification for fields in the generated files.',
7878
default: markdownDefaults.includeFieldSecurityMetadata,
79-
}
79+
},
80+
includeInlineHelpTextMetadata: {
81+
type: 'boolean',
82+
describe: 'Whether to include the inline help text for fields in the generated files.',
83+
},
8084
};

src/core/changelog/__test__/helpers/custom-field-metadata-builder.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default class CustomFieldMetadataBuilder {
2525
required: false,
2626
securityClassification: 'Internal',
2727
complianceGroup: 'PII',
28+
inlineHelpText: 'An image in either one of the following formats: JPEG, SVG, or PNG. For best results the image should be under 1MB in size.',
2829
};
2930
}
3031
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export function generateDocs(bundles: UnparsedSourceBundle[], config?: Partial<M
5757
excludeTags: [],
5858
referenceGuideTitle: 'Apex Reference Guide',
5959
includeFieldSecurityMetadata: true,
60+
includeInlineHelpTextMetadata: true,
6061
exclude: [],
6162
...config,
6263
});

src/core/markdown/adapters/__tests__/interface-adapter.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const defaultMarkdownGeneratorConfig: MarkdownGeneratorConfig = {
2121
linkingStrategy: 'relative',
2222
referenceGuideTitle: 'Apex Reference Guide',
2323
includeFieldSecurityMetadata: true,
24+
includeInlineHelpTextMetadata: true,
2425
exclude: [],
2526
excludeTags: [],
2627
};

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ function fieldMetadataToRenderable(
359359
required: field.required,
360360
complianceGroup: renderComplianceGroup(field.complianceGroup, config),
361361
securityClassification: renderComplianceGroup(field.securityClassification, config),
362+
inlineHelpText: renderInlineHelpText(field.inlineHelpText, config),
362363
pickListValues: field.pickListValues
363364
? {
364365
headingLevel: headingLevel + 1,
@@ -401,3 +402,11 @@ function renderComplianceGroup(complianceGroup: string | null, config: MarkdownG
401402
return null;
402403
}
403404
}
405+
function renderInlineHelpText(inlineHelpText: string | null, config: MarkdownGeneratorConfig) {
406+
if(config.includeInlineHelpTextMetadata) {
407+
return inlineHelpText
408+
} else {
409+
return null;
410+
}
411+
}
412+

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export const customObjectTemplate = `
2424
{{{renderContent description}}}
2525
{{/if}}
2626
27+
{{#if inlineHelpText}}
28+
**Inline Help Text**
29+
{{inlineHelpText}}
30+
{{/if}}
31+
2732
{{#if complianceGroup}}
2833
**Compliance Group**
2934
{{complianceGroup}}

src/core/reflection/sobject/__test__/reflect-custom-field-sources.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const customFieldContent = `
1616
<description>A Photo URL field</description>
1717
<securityClassification>Internal</securityClassification>
1818
<complianceGroup>PII</complianceGroup>
19+
<inlineHelpText>An image in either one of the following formats: JPEG, SVG, or PNG. For best results the image should be under 1MB in size.</inlineHelpText>
1920
</CustomField>`;
2021

2122
describe('when parsing custom field metadata', () => {
@@ -137,6 +138,20 @@ describe('when parsing custom field metadata', () => {
137138
assertEither(result, (data) => expect(data[0].type.complianceGroup).toBe('PII'));
138139
});
139140

141+
test('the resulting type contains the correct inline help text', async () => {
142+
const unparsed: UnparsedCustomFieldBundle = {
143+
type: 'customfield',
144+
name: 'PhotoUrl__c',
145+
parentName: 'MyFirstObject__c',
146+
filePath: 'src/field/PhotoUrl__c.field-meta.xml',
147+
content: customFieldContent,
148+
};
149+
150+
const result = await reflectCustomFieldSources([unparsed])();
151+
152+
assertEither(result, (data) => expect(data[0].type.inlineHelpText).toBe('An image in either one of the following formats: JPEG, SVG, or PNG. For best results the image should be under 1MB in size.'));
153+
});
154+
140155
test('can parse picklist values when there are multiple picklist values available', async () => {
141156
const unparsed: UnparsedCustomFieldBundle = {
142157
type: 'customfield',

src/core/reflection/sobject/reflect-custom-field-source.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type CustomFieldMetadata = {
2020
required: boolean;
2121
securityClassification: string | null;
2222
complianceGroup: string | null;
23+
inlineHelpText: string | null;
2324
};
2425

2526
export function reflectCustomFieldSources(
@@ -70,6 +71,7 @@ function toCustomFieldMetadata(parserResult: { CustomField: unknown }): CustomFi
7071
required: false,
7172
securityClassification: null,
7273
complianceGroup: null,
74+
inlineHelpText: null,
7375
};
7476

7577
return {

src/core/reflection/sobject/reflect-custom-object-sources.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ function convertInlineFieldsToCustomFieldMetadata(
111111
const required = inlineField.required ? (inlineField.required as boolean) : false;
112112
const securityClassification = inlineField.securityClassification ? (inlineField.securityClassification as string) : null;
113113
const complianceGroup = inlineField.complianceGroup ? (inlineField.complianceGroup as string) : null;
114+
const inlineHelpText = inlineField.inlineHelpText ? (inlineField.inlineHelpText as string) : null;
114115

115116
return {
116117
type_name: 'customfield',
@@ -122,6 +123,7 @@ function convertInlineFieldsToCustomFieldMetadata(
122123
required,
123124
securityClassification,
124125
complianceGroup,
126+
inlineHelpText,
125127
pickListValues: getPickListValues(inlineField),
126128
};
127129
}

0 commit comments

Comments
 (0)