Skip to content

Commit c756c67

Browse files
committed
Configurable custom object visibility
1 parent 92259e4 commit c756c67

File tree

9 files changed

+42
-8
lines changed

9 files changed

+42
-8
lines changed

src/cli/commands/markdown.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export const markdownOptions: Record<keyof CliConfigurableMarkdownConfig, Option
2424
'A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. ' +
2525
'Annotations are supported and should be passed lowercased and without the @ symbol, e.g. namespaceaccessible auraenabled.',
2626
},
27+
customObjectVisibility: {
28+
type: 'string',
29+
array: true,
30+
alias: 'v',
31+
default: markdownDefaults.customObjectVisibility,
32+
choices: ['public', 'protected', 'packageprotected'],
33+
describe: 'Controls which custom objects are documented. Values should be separated by a space.',
34+
},
2735
defaultGroupName: {
2836
type: 'string',
2937
default: markdownDefaults.defaultGroupName,

src/core/changelog/generate-change-log.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ function reflect(bundles: UnparsedSourceBundle[], config: Omit<UserDefinedChange
7171
reflectApexFiles(filterApexSourceFiles(bundles)),
7272
TE.chain((parsedApexFiles) => {
7373
return pipe(
74-
reflectCustomFieldsAndObjectsAndMetadataRecords(filterCustomObjectsFieldsAndMetadataRecords(bundles)),
74+
reflectCustomFieldsAndObjectsAndMetadataRecords(filterCustomObjectsFieldsAndMetadataRecords(bundles), [
75+
'public', // TODO: Do not hardcode
76+
]),
7577
TE.map((parsedObjectFiles) => [...parsedApexFiles, ...parsedObjectFiles]),
7678
);
7779
}),

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,25 @@ describe('When generating documentation', () => {
160160
expect(result).documentationBundleHasLength(0);
161161
});
162162

163-
it('does not return non-public custom objects', async () => {
164-
const input = new CustomObjectXmlBuilder().withVisibility('Protected').build();
165-
166-
const result = await generateDocs([unparsedObjectBundleFromRawString({ rawContent: input, filePath: 'test' })])();
167-
expect(result).documentationBundleHasLength(0);
163+
describe('and the custom object visibility', () => {
164+
it('is not set, it does not return non-public custom objects', async () => {
165+
const input = new CustomObjectXmlBuilder().withVisibility('Protected').build();
166+
167+
const result = await generateDocs([
168+
unparsedObjectBundleFromRawString({ rawContent: input, filePath: 'test' }),
169+
])();
170+
expect(result).documentationBundleHasLength(0);
171+
});
172+
173+
it('is configured, it respects the configured visibility', async () => {
174+
const input = new CustomObjectXmlBuilder().withVisibility('Protected').build();
175+
176+
const result = await generateDocs(
177+
[unparsedObjectBundleFromRawString({ rawContent: input, filePath: 'test' })],
178+
{ customObjectVisibility: ['protected'] },
179+
)();
180+
expect(result).documentationBundleHasLength(1);
181+
});
168182
});
169183

170184
it('do not return files that have an @ignore in the docs', async () => {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function generateDocs(bundles: UnparsedSourceBundle[], config?: Partial<M
2929
return gen(bundles, {
3030
targetDir: 'target',
3131
scope: ['global', 'public'],
32+
customObjectVisibility: ['public'],
3233
defaultGroupName: 'Miscellaneous',
3334
customObjectsGroupName: 'Custom Objects',
3435
sortAlphabetically: false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function linkGenerator(type: string): string {
1111
const defaultMarkdownGeneratorConfig: MarkdownGeneratorConfig = {
1212
targetDir: '',
1313
scope: ['global', 'public'],
14+
customObjectVisibility: ['public'],
1415
namespace: '',
1516
defaultGroupName: 'Miscellaneous',
1617
customObjectsGroupName: 'Custom Objects',

src/core/markdown/generate-docs.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ export function generateDocs(unparsedBundles: UnparsedSourceBundle[], config: Ma
6363
generateForApex(filterApexSourceFiles(unparsedBundles), config),
6464
TE.chain((parsedApexFiles) => {
6565
return pipe(
66-
reflectCustomFieldsAndObjectsAndMetadataRecords(filterCustomObjectsFieldsAndMetadataRecords(unparsedBundles)),
66+
reflectCustomFieldsAndObjectsAndMetadataRecords(
67+
filterCustomObjectsFieldsAndMetadataRecords(unparsedBundles),
68+
config.customObjectVisibility,
69+
),
6770
TE.map((parsedObjectFiles) => [...parsedApexFiles, ...parsedObjectFiles]),
6871
);
6972
}),

src/core/reflection/sobject/reflectCustomFieldsAndObjectsAndMetadataRecords.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ import { CustomMetadataMetadata, reflectCustomMetadataSources } from './reflect-
1414

1515
export function reflectCustomFieldsAndObjectsAndMetadataRecords(
1616
objectBundles: (UnparsedCustomObjectBundle | UnparsedCustomFieldBundle | UnparsedCustomMetadataBundle)[],
17+
visibilitiesToDocument: string[],
1718
): TaskEither<ReflectionErrors, ParsedFile<CustomObjectMetadata>[]> {
1819
function filterNonPublished(parsedFiles: ParsedFile<CustomObjectMetadata>[]): ParsedFile<CustomObjectMetadata>[] {
1920
return parsedFiles.filter((parsedFile) => parsedFile.type.deploymentStatus === 'Deployed');
2021
}
2122

2223
function filterNonPublic(parsedFiles: ParsedFile<CustomObjectMetadata>[]): ParsedFile<CustomObjectMetadata>[] {
23-
return parsedFiles.filter((parsedFile) => parsedFile.type.visibility === 'Public');
24+
return parsedFiles.filter((parsedFile) =>
25+
visibilitiesToDocument.includes(parsedFile.type.visibility.toLowerCase()),
26+
);
2427
}
2528

2629
const customObjects = objectBundles.filter(

src/core/shared/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type CliConfigurableMarkdownConfig = {
2020
sourceDir: string;
2121
targetDir: string;
2222
scope: string[];
23+
customObjectVisibility: string[];
2324
namespace?: string;
2425
defaultGroupName: string;
2526
customObjectsGroupName: string;

src/defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const commonDefaults = {
33
};
44

55
export const markdownDefaults = {
6+
customObjectVisibility: ['public'],
67
...commonDefaults,
78
scope: ['global'],
89
defaultGroupName: 'Miscellaneous',

0 commit comments

Comments
 (0)