Skip to content

Commit 6439ced

Browse files
authored
Merge pull request #204 from cesarParra/standard-object-parsing-error
Standard object parsing error
2 parents 4b9eada + 633df67 commit 6439ced

File tree

14 files changed

+146
-133
lines changed

14 files changed

+146
-133
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Account
2+
3+
## API Name
4+
`ns__Account`
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Contact
2+
3+
## API Name
4+
`ns__Contact`
5+
6+
## Fields
7+
### PhotoUrl
8+
9+
**API Name**
10+
11+
`ns__PhotoUrl__c`
12+
13+
**Type**
14+
15+
*Url*

examples/markdown/docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Custom Objects
44

5+
### [Account](custom-objects/Account.md)
6+
7+
### [Contact](custom-objects/Contact.md)
8+
59
### [Event__c](custom-objects/Event__c.md)
610

711
Represents an event that people can register for.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<actionOverrides>
4+
<actionName>CallHighlightAction</actionName>
5+
<type>Default</type>
6+
</actionOverrides>
7+
<actionOverrides>
8+
<actionName>CancelEdit</actionName>
9+
<type>Default</type>
10+
</actionOverrides>
11+
<actionOverrides>
12+
<actionName>Delete</actionName>
13+
<type>Default</type>
14+
</actionOverrides>
15+
<actionOverrides>
16+
<actionName>Edit</actionName>
17+
<type>Default</type>
18+
</actionOverrides>
19+
<actionOverrides>
20+
<actionName>EmailHighlightAction</actionName>
21+
<type>Default</type>
22+
</actionOverrides>
23+
<actionOverrides>
24+
<actionName>EnableCustomerPortalUser</actionName>
25+
<type>Default</type>
26+
</actionOverrides>
27+
<actionOverrides>
28+
<actionName>List</actionName>
29+
<type>Default</type>
30+
</actionOverrides>
31+
<actionOverrides>
32+
<actionName>ListClean</actionName>
33+
<type>Default</type>
34+
</actionOverrides>
35+
<actionOverrides>
36+
<actionName>New</actionName>
37+
<type>Default</type>
38+
</actionOverrides>
39+
<actionOverrides>
40+
<actionName>RequestUpdate</actionName>
41+
<type>Default</type>
42+
</actionOverrides>
43+
<actionOverrides>
44+
<actionName>SaveEdit</actionName>
45+
<type>Default</type>
46+
</actionOverrides>
47+
<actionOverrides>
48+
<actionName>SmsHighlightAction</actionName>
49+
<type>Default</type>
50+
</actionOverrides>
51+
<actionOverrides>
52+
<actionName>Tab</actionName>
53+
<type>Default</type>
54+
</actionOverrides>
55+
<actionOverrides>
56+
<actionName>View</actionName>
57+
<content>Account_Record_Page</content>
58+
<formFactor>Large</formFactor>
59+
<skipRecordTypeSelect>false</skipRecordTypeSelect>
60+
<type>Flexipage</type>
61+
</actionOverrides>
62+
<actionOverrides>
63+
<actionName>ViewCustomerPortalUser</actionName>
64+
<type>Default</type>
65+
</actionOverrides>
66+
<actionOverrides>
67+
<actionName>WebsiteHighlightAction</actionName>
68+
<type>Default</type>
69+
</actionOverrides>
70+
<compactLayoutAssignment>Account_Compact_Layout</compactLayoutAssignment>
71+
<enableEnhancedLookup>true</enableEnhancedLookup>
72+
<enableFeeds>true</enableFeeds>
73+
<enableHistory>false</enableHistory>
74+
<searchLayouts>
75+
<customTabListAdditionalFields>ACCOUNT.NAME</customTabListAdditionalFields>
76+
<customTabListAdditionalFields>ACCOUNT.ADDRESS1_CITY</customTabListAdditionalFields>
77+
<customTabListAdditionalFields>ACCOUNT.PHONE1</customTabListAdditionalFields>
78+
<lookupDialogsAdditionalFields>ACCOUNT.NAME</lookupDialogsAdditionalFields>
79+
<lookupDialogsAdditionalFields>CORE.USERS.ALIAS</lookupDialogsAdditionalFields>
80+
<lookupDialogsAdditionalFields>ACCOUNT.TYPE</lookupDialogsAdditionalFields>
81+
<lookupPhoneDialogsAdditionalFields>ACCOUNT.NAME</lookupPhoneDialogsAdditionalFields>
82+
<lookupPhoneDialogsAdditionalFields>CORE.USERS.ALIAS</lookupPhoneDialogsAdditionalFields>
83+
<lookupPhoneDialogsAdditionalFields>ACCOUNT.TYPE</lookupPhoneDialogsAdditionalFields>
84+
<lookupPhoneDialogsAdditionalFields>ACCOUNT.PHONE1</lookupPhoneDialogsAdditionalFields>
85+
<searchResultsAdditionalFields>ACCOUNT.NAME</searchResultsAdditionalFields>
86+
<searchResultsAdditionalFields>ACCOUNT.PHONE1</searchResultsAdditionalFields>
87+
<searchResultsAdditionalFields>CORE.USERS.ALIAS</searchResultsAdditionalFields>
88+
</searchLayouts>
89+
<sharingModel>ReadWrite</sharingModel>
90+
</CustomObject>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
3+
</CustomObject>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cparra/apexdocs",
3-
"version": "3.4.1",
3+
"version": "3.4.2",
44
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
55
"keywords": [
66
"apex",

src/application/source-code-file-reader.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,16 @@ export function processFiles(fileSystem: FileSystem) {
155155
return (rootPath: string, exclude: string[]) => {
156156
return pipe(
157157
fileSystem.getComponents(rootPath),
158-
(components) => components.filter((component) => !isExcluded(component.content!, exclude)),
158+
(components) => {
159+
return components.map((component) => {
160+
const pathLocation = component.type.name === 'ApexClass' ? component.content : component.xml;
161+
return {
162+
...component,
163+
filePath: pathLocation!,
164+
};
165+
});
166+
},
167+
(components) => components.filter((component) => !isExcluded(component.filePath, exclude)),
159168
(components) => convertersToUse.map((converter) => converter(components)),
160169
(bundles) => bundles.flat(),
161170
);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function objectMetadataToRenderable(
254254
type: 'customobject',
255255
headingLevel: 1,
256256
apiName: getApiName(objectMetadata.name, config),
257-
heading: objectMetadata.label,
257+
heading: objectMetadata.label ?? objectMetadata.name,
258258
name: objectMetadata.name,
259259
doc: {
260260
description: objectMetadata.description ? [objectMetadata.description] : [],
@@ -277,7 +277,7 @@ function fieldMetadataToRenderable(
277277
return {
278278
type: 'field',
279279
headingLevel: headingLevel,
280-
heading: field.label,
280+
heading: field.label ?? field.name,
281281
description: field.description ? [field.description] : [],
282282
apiName: getApiName(field.name, config),
283283
fieldType: field.type,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ export const customObjectTemplate = `
1919
2020
\`{{{apiName}}}\`
2121
22+
{{#if fieldType}}
2223
**Type**
2324
2425
*{{fieldType}}*
26+
{{/if}}
2527
2628
{{#unless @last}}---{{/unless}}
2729
{{/each}}

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

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -137,66 +137,4 @@ describe('when parsing custom field metadata', () => {
137137

138138
expect(E.isLeft(result)).toBe(true);
139139
});
140-
141-
test('An error is returned when the CustomField key is not an object', 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: `
148-
<?xml version="1.0" encoding="UTF-8"?>
149-
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">invalid</CustomField>`,
150-
};
151-
152-
const result = await reflectCustomFieldSources([unparsed])();
153-
154-
expect(E.isLeft(result)).toBe(true);
155-
});
156-
157-
test('An error is returned when the CustomKey object does not contain the label key', async () => {
158-
const unparsed: UnparsedCustomFieldBundle = {
159-
type: 'customfield',
160-
name: 'PhotoUrl__c',
161-
parentName: 'MyFirstObject__c',
162-
filePath: 'src/field/PhotoUrl__c.field-meta.xml',
163-
content: `
164-
<?xml version="1.0" encoding="UTF-8"?>
165-
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
166-
<fullName>PhotoUrl__c</fullName>
167-
<externalId>false</externalId>
168-
<required>false</required>
169-
<trackFeedHistory>false</trackFeedHistory>
170-
<type>Url</type>
171-
<description>A Photo URL field</description>
172-
</CustomField>`,
173-
};
174-
175-
const result = await reflectCustomFieldSources([unparsed])();
176-
177-
expect(E.isLeft(result)).toBe(true);
178-
});
179-
180-
test('An error is returned when the CustomKey object does not contain the type key', async () => {
181-
const unparsed: UnparsedCustomFieldBundle = {
182-
type: 'customfield',
183-
name: 'PhotoUrl__c',
184-
parentName: 'MyFirstObject__c',
185-
filePath: 'src/field/PhotoUrl__c.field-meta.xml',
186-
content: `
187-
<?xml version="1.0" encoding="UTF-8"?>
188-
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
189-
<fullName>PhotoUrl__c</fullName>
190-
<externalId>false</externalId>
191-
<label>PhotoUrl</label>
192-
<required>false</required>
193-
<trackFeedHistory>false</trackFeedHistory>
194-
<description>A Photo URL field</description>
195-
</CustomField>`,
196-
};
197-
198-
const result = await reflectCustomFieldSources([unparsed])();
199-
200-
expect(E.isLeft(result)).toBe(true);
201-
});
202140
});

0 commit comments

Comments
 (0)