Skip to content
Merged
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ apexdocs changelog --previousVersionDir force-app-previous --currentVersionDir f
| `--linkingStrategy` | N/A | The strategy to use when linking to other classes. Possible values are `relative`, `no-link`, and `none` | `relative` | No |
| `--customObjectsGroupName` | N/A | The name under which custom objects will be grouped in the Reference Guide | `Custom Objects` | No |
| `--triggersGroupName` | N/A | The name under which triggers will be grouped in the Reference Guide | `Triggers` | No |
| `--includeFieldSecurityMetadata` | N/A | Whether to include the compliance category and security classification for fields in the generated files. | `false` | No |
| `--includeInlineHelpTextMetadata` | N/A | Whether to include the inline help text for fields in the generated files. | `false` | No |

##### Linking Strategy

Expand Down
2 changes: 1 addition & 1 deletion examples/markdown/docs/custom-objects/Event__c.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Represents an event that people can register for.

Used to store the U.S. social security number in 9 digit format.

**Compliance Category**
**Compliance Group**
PII

**Security Classification**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<fullName>Social_Security_Number__c</fullName>
<externalId>false</externalId>
<label>Social Security Number</label>
<inlineHelpText>You indicated the approval for storage of your social security number.</inlineHelpText>
<description>Used to store the U.S. social security number in 9 digit format.</description>
<length>9</length>
<trackTrending>false</trackTrending>
<type>Text</type>
<complianceCategory>PII</complianceCategory>
<complianceGroup>PII</complianceGroup>
<securityClassification>Internal</securityClassification>
</CustomField>
6 changes: 5 additions & 1 deletion src/cli/commands/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,9 @@ export const markdownOptions: Record<keyof CliConfigurableMarkdownConfig, Option
type: 'boolean',
describe: 'Whether to include the compliance category and security classification for fields in the generated files.',
default: markdownDefaults.includeFieldSecurityMetadata,
}
},
includeInlineHelpTextMetadata: {
type: 'boolean',
describe: 'Whether to include the inline help text for fields in the generated files.',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default class CustomFieldMetadataBuilder {
parentName: 'MyObject',
required: false,
securityClassification: 'Internal',
complianceCategory: 'PII',
complianceGroup: 'PII',
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.',
};
}
}
1 change: 1 addition & 0 deletions src/core/markdown/__test__/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export function generateDocs(bundles: UnparsedSourceBundle[], config?: Partial<M
excludeTags: [],
referenceGuideTitle: 'Apex Reference Guide',
includeFieldSecurityMetadata: true,
includeInlineHelpTextMetadata: true,
exclude: [],
...config,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const defaultMarkdownGeneratorConfig: MarkdownGeneratorConfig = {
linkingStrategy: 'relative',
referenceGuideTitle: 'Apex Reference Guide',
includeFieldSecurityMetadata: true,
includeInlineHelpTextMetadata: true,
exclude: [],
excludeTags: [],
};
Expand Down
17 changes: 13 additions & 4 deletions src/core/markdown/adapters/type-to-renderable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,9 @@ function fieldMetadataToRenderable(
apiName: getApiName(field.name, config),
fieldType: field.type,
required: field.required,
complianceCategory: renderComplianceCategory(field.complianceCategory, config),
securityClassification: renderComplianceCategory(field.securityClassification, config),
complianceGroup: renderComplianceGroup(field.complianceGroup, config),
securityClassification: renderComplianceGroup(field.securityClassification, config),
inlineHelpText: renderInlineHelpText(field.inlineHelpText, config),
pickListValues: field.pickListValues
? {
headingLevel: headingLevel + 1,
Expand Down Expand Up @@ -394,10 +395,18 @@ function getApiName(currentName: string, config: MarkdownGeneratorConfig) {
return currentName;
}

function renderComplianceCategory(complianceCategory: string | null, config: MarkdownGeneratorConfig) {
function renderComplianceGroup(complianceGroup: string | null, config: MarkdownGeneratorConfig) {
if(config.includeFieldSecurityMetadata) {
return complianceCategory;
return complianceGroup;
} else {
return null;
}
}
function renderInlineHelpText(inlineHelpText: string | null, config: MarkdownGeneratorConfig) {
if(config.includeInlineHelpTextMetadata) {
return inlineHelpText
} else {
return null;
}
}

11 changes: 8 additions & 3 deletions src/core/markdown/templates/custom-object-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ export const customObjectTemplate = `
{{{renderContent description}}}
{{/if}}

{{#if complianceCategory}}
**Compliance Category**
{{complianceCategory}}
{{#if inlineHelpText}}
**Inline Help Text**
{{inlineHelpText}}
{{/if}}

{{#if complianceGroup}}
**Compliance Group**
{{complianceGroup}}
{{/if}}

{{#if securityClassification}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const customFieldContent = `
<type>Url</type>
<description>A Photo URL field</description>
<securityClassification>Internal</securityClassification>
<complianceCategory>PII</complianceCategory>
<complianceGroup>PII</complianceGroup>
<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>
</CustomField>`;

describe('when parsing custom field metadata', () => {
Expand Down Expand Up @@ -123,7 +124,7 @@ describe('when parsing custom field metadata', () => {
assertEither(result, (data) => expect(data[0].type.securityClassification).toBe('Internal'));
});

test('the resulting type contains the correct compliance category', async () => {
test('the resulting type contains the correct compliance group', async () => {
const unparsed: UnparsedCustomFieldBundle = {
type: 'customfield',
name: 'PhotoUrl__c',
Expand All @@ -134,7 +135,21 @@ describe('when parsing custom field metadata', () => {

const result = await reflectCustomFieldSources([unparsed])();

assertEither(result, (data) => expect(data[0].type.complianceCategory).toBe('PII'));
assertEither(result, (data) => expect(data[0].type.complianceGroup).toBe('PII'));
});

test('the resulting type contains the correct inline help text', async () => {
const unparsed: UnparsedCustomFieldBundle = {
type: 'customfield',
name: 'PhotoUrl__c',
parentName: 'MyFirstObject__c',
filePath: 'src/field/PhotoUrl__c.field-meta.xml',
content: customFieldContent,
};

const result = await reflectCustomFieldSources([unparsed])();

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.'));
});

test('can parse picklist values when there are multiple picklist values available', async () => {
Expand Down
6 changes: 4 additions & 2 deletions src/core/reflection/sobject/reflect-custom-field-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export type CustomFieldMetadata = {
pickListValues?: string[];
required: boolean;
securityClassification: string | null;
complianceCategory: string | null;
complianceGroup: string | null;
inlineHelpText: string | null;
};

export function reflectCustomFieldSources(
Expand Down Expand Up @@ -69,7 +70,8 @@ function toCustomFieldMetadata(parserResult: { CustomField: unknown }): CustomFi
description: null,
required: false,
securityClassification: null,
complianceCategory: null,
complianceGroup: null,
inlineHelpText: null,
};

return {
Expand Down
6 changes: 4 additions & 2 deletions src/core/reflection/sobject/reflect-custom-object-sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ function convertInlineFieldsToCustomFieldMetadata(
const type = inlineField.type ? (inlineField.type as string) : null;
const required = inlineField.required ? (inlineField.required as boolean) : false;
const securityClassification = inlineField.securityClassification ? (inlineField.securityClassification as string) : null;
const complianceCategory = inlineField.complianceCategory ? (inlineField.complianceCategory as string) : null;
const complianceGroup = inlineField.complianceGroup ? (inlineField.complianceGroup as string) : null;
const inlineHelpText = inlineField.inlineHelpText ? (inlineField.inlineHelpText as string) : null;

return {
type_name: 'customfield',
Expand All @@ -121,7 +122,8 @@ function convertInlineFieldsToCustomFieldMetadata(
type,
required,
securityClassification,
complianceCategory,
complianceGroup,
inlineHelpText,
pickListValues: getPickListValues(inlineField),
};
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/renderables/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,9 @@ export type RenderableCustomField = {
type: 'field';
fieldType?: string | null;
required: boolean;
complianceCategory: string | null;
complianceGroup: string | null;
securityClassification: string | null;
inlineHelpText: string | null;
};

export type RenderableCustomMetadata = {
Expand Down
1 change: 1 addition & 0 deletions src/core/shared/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export type CliConfigurableMarkdownConfig = {
linkingStrategy: LinkingStrategy;
referenceGuideTitle: string;
includeFieldSecurityMetadata: boolean;
includeInlineHelpTextMetadata: boolean;
};

export type UserDefinedMarkdownConfig = {
Expand Down
1 change: 1 addition & 0 deletions src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const markdownDefaults = {
referenceGuideTitle: 'Reference Guide',
excludeTags: [],
includeFieldSecurityMetadata: false,
includeInlineHelpTextMetadata: false,
};

export const openApiDefaults = {
Expand Down