Skip to content

Commit b132e36

Browse files
Merge pull request #1 from williamsalexisSFDC/feature/test-security-changes
Add ability to have Inline Help Text generated in markdown from the Salesforce Field metadata
2 parents 73b78bf + 77d9154 commit b132e36

File tree

14 files changed

+46
-1
lines changed

14 files changed

+46
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ apexdocs changelog --previousVersionDir force-app-previous --currentVersionDir f
125125
| `--customObjectsGroupName` | N/A | The name under which custom objects will be grouped in the Reference Guide | `Custom Objects` | No |
126126
| `--triggersGroupName` | N/A | The name under which triggers will be grouped in the Reference Guide | `Triggers` | No |
127127
| `--includeFieldSecurityMetadata` | N/A | Whether to include the compliance category and security classification for fields in the generated files. | `false` | No |
128+
| `--includeInlineHelpTextMetadata` | N/A | Whether to include the inline help text for fields in the generated files. | `false` | No |
128129

129130
##### Linking Strategy
130131

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 {

0 commit comments

Comments
 (0)