Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,13 @@ export const Property: FunctionComponent<{
return (
<tr ref={propertyRef} className={legacyStyles.tableRow}>
<td className={legacyStyles.propertyNameDescription}>
<div className={classnames(styles.propertyRow)}>
<div className={classnames(styles.propertyRow)} data-api-property>
<div className={styles.leftColumn}>
<div id={idName} className={classnames(styles.name, 'side-menu-exclude')}>
<div
id={idName}
className={classnames(styles.name, 'side-menu-exclude')}
data-api-property-name
>
<span dangerouslySetInnerHTML={{ __html: displayNameSplit }}></span>
<LinkIcon
href={`#${idName}`}
Expand Down Expand Up @@ -331,6 +335,7 @@ export const Property: FunctionComponent<{
<div
role="presentation"
className={styles.description}
data-api-property-description
dangerouslySetInnerHTML={{ __html: removeDefaultValue(description) }}
></div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export const Section: FunctionComponent<SectionProps> = ({
/>
)}
<table
data-api-reference-table
className={classnames(styles.reference, styles.apiReference, legacyStyles.apiReference, 'no-zebra')}
style={config.overrideBottomMargin ? { marginBottom: config.overrideBottomMargin } : {}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ interface MetaTag {
};
type?: string;
isEvent?: boolean;
/** Suppress the missing property check. Needed for events as they are dynamic and so do not appear in src code */
suppressMissingPropCheck?: true;
}
export type DocEntryMap = Record<string, DocEntry | ChildDocEntry>;
type DocEntry = {
Expand Down Expand Up @@ -173,9 +171,6 @@ export interface Config {
headerLevel?: number;
/** Set the margin-bottom value to override the default of 3em */
overrideBottomMargin?: string;
/** Suppress the missing property check. Needed for events as they are dynamic and so do not appear in src code */
suppressMissingPropCheck?: true;

/** A regular expression limiting the names that should appear */
namePattern: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const getPropertiesFromSource = async ({
sources: string[];
}) => {
const sources = source ? [source] : sourcesProp;
const propertiesFromFilesPromises = sources.map(async (s: string) => {
const fileEntryPromises = sources.map(async (s: string) => {
// NOTE: Need to remove `.json` for getEntry
const fileName = s.replace('.json', '');
const fileEntry = await getEntry('apiDocumentation', fileName);
Expand All @@ -26,35 +26,45 @@ export const getPropertiesFromSource = async ({
} else {
throw new Error(message);
}
} else {
return fileEntry.data;
}
return fileEntry;
});
const propertiesFromFiles = (await Promise.all(propertiesFromFilesPromises)).filter(Boolean);
const fileEntries = await Promise.all(fileEntryPromises);

const propertyConfigs = propertiesFromFiles
.map((p) => {
const config = p['_config_'];
if (!config) {
// eslint-disable-next-line no-console
console.warn(`ApiDocumentation: _config_ property missing from source ${sources.join()}.`);
}
return config;
})
.filter(Boolean);
const codeConfigEntries = propertyConfigs
.map((config) => config.codeSrc)
.map((fileName) => {
const referenceFileName = `reference/${fileName}`;
const file = getJsonFile(referenceFileName);
return [fileName, file];
});
const codeConfigs = Object.fromEntries(codeConfigEntries);
const propertiesFromFiles: any[] = [];
const propertyConfigs: any[] = [];
const codeConfigs: Record<string, any> = {};

for (let i = 0; i < sources.length; i++) {
const fileEntry = fileEntries[i];
if (!fileEntry) {
continue;
}

// Validate that theming-api/properties.json keys match the theming-api.AUTO.json keys
// Only run when actually processing the theming-api source
if (sources.some((s) => s.includes('theming-api'))) {
validateThemingApiProperties(propertiesFromFiles, codeConfigs);
const s = sources[i];
const propsFile = fileEntry.data;
propertiesFromFiles.push(propsFile);

const config = propsFile['_config_'];
if (!config) {
// eslint-disable-next-line no-console
console.warn(`ApiDocumentation: _config_ property missing from source ${s}.`);
continue;
}
propertyConfigs.push(config);

const codeSrc = config.codeSrc;
if (codeSrc && !(codeSrc in codeConfigs)) {
codeConfigs[codeSrc] = getJsonFile(`reference/${codeSrc}`);
}

if (config.validate) {
const codeConfig = codeConfigs[codeSrc];
if (!codeConfig) {
throw new Error(`${s} codeSrc file not found: ${codeSrc}`);
}
validateDocumentedProperties(propsFile, codeConfig, s);
}
}

return {
Expand All @@ -65,32 +75,54 @@ export const getPropertiesFromSource = async ({
};
};

function validateThemingApiProperties(properties: any[], codeConfigs: any) {
const codeSrc = 'theming-api.AUTO.json';
const propsFile = properties.find((p) => p['_config_']?.codeSrc === codeSrc);
if (!propsFile) {
throw new Error(`No properties.json with codeSrc: "${codeSrc}"`);
}
const codeConfig = codeConfigs[codeSrc];
if (!codeConfig) {
throw new Error(`Theme params codeSrc file not found: ${codeSrc}`);
}
const codeKeys = new Set(Object.keys(codeConfig));
const propsKeys = Object.entries(propsFile)
function validateDocumentedProperties(propsFile: any, codeConfig: any, source: string) {
const config = propsFile['_config_'];
const codeSrc = config.codeSrc;
const undocumentedProperties = config.undocumentedProperties ?? {};

const keysToDocument = new Set(
Object.keys(codeConfig).filter((k) => {
if (k in undocumentedProperties) {
return false;
}
const entry = codeConfig[k];
if (entry?.meta?.tags?.some((t: any) => t.name === 'deprecated')) {
return false;
}
if (config.excludeEvents && entry?.meta?.isEvent) {
return false;
}
if (config.onlyEvents) {
if (!entry?.meta?.isEvent) {
return false;
}
// Events like onCellClicked are the grid option callback form;
// event docs use the unprefixed name (cellClicked)
if (/^on[A-Z]/.test(k)) {
return false;
}
}
return true;
})
);

const documentedKeys = Object.entries(propsFile)
.filter(([k]) => k !== '_config_')
.flatMap(([, section]) => Object.keys(section as object).filter((k) => k !== 'meta'));
const missing = propsKeys.filter((k) => !codeKeys.has(k));
const extra = [...codeKeys].filter((k) => !propsKeys.includes(k));
if (missing.length || extra.length) {

const stale = documentedKeys.filter((k) => !keysToDocument.has(k));
const undocumented = [...keysToDocument].filter((k) => !documentedKeys.includes(k));

if (stale.length || undocumented.length) {
const msgs: string[] = [];
if (missing.length) {
if (stale.length) {
msgs.push(
`These theme params are documented in theming-api/properties.json but not in the API (checking ${codeSrc}): ${missing.join(', ')}`
`These ${source} keys are documented but not in the API (checking ${codeSrc}): ${stale.join(', ')}`
);
}
if (extra.length) {
if (undocumented.length) {
msgs.push(
`These theme params are present in the API (checking ${codeSrc}) but not documented in theming-api/properties.json: ${extra.join(', ')}`
`These ${source} keys are present in the API (checking ${codeSrc}) but not documented: ${undocumented.join(', ')}`
);
}
throw new Error(msgs.join('\n'));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"events": {
"meta": {
"displayName": "Events on Column",
"isEvent": true,
"suppressMissingPropCheck": true
"isEvent": true
},
"filterActiveChanged": {
"description": "The filter active value has changed.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"_config_": {
"codeSrc": "columnGroup.AUTO.json"
"codeSrc": "columnGroup.AUTO.json",
"validate": true,
"undocumentedProperties": {
"getDefinition": "Alias of getColGroupDef, the specific version is preferred",
"getUniqueId": "Alias of getColId on the underlying columns"
}
},
"ColumnGroup": {
"getColGroupDef": {},
Expand All @@ -15,6 +20,14 @@
"isExpanded": {},
"isPadding": {},
"getPaddingLevel": {},
"isColumn": {}
"isColumn": {},
"getActualWidth": {},
"getMinWidth": {},
"getLeft": {},
"getColumnGroupShow": {},
"getParent": {},
"isEmptyGroup": {},
"isMoving": {},
"getPinned": {}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"_config_": {
"codeSrc": "providedColumnGroup.AUTO.json"
"codeSrc": "providedColumnGroup.AUTO.json",
"validate": true,
"undocumentedProperties": {
"getId": "Alias of getGroupId"
}
},
"ProvidedColumnGroup": {
"getOriginalParent": {},
Expand All @@ -12,6 +16,8 @@
"getChildren": {},
"getColGroupDef": {},
"getLeafColumns": {},
"isColumn": {}
"isColumn": {},
"isVisible": {},
"getColumnGroupShow": {}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"_config_": {
"codeSrc": "column.AUTO.json"
"codeSrc": "column.AUTO.json",
"validate": true,
"undocumentedProperties": {
"getDefinition": "Alias of getColDef, the specific version is preferred",
"getUniqueId": "Alias of getColId",
"getId": "Alias of getColId",
"getRowSpan": "Same functionality as rowSpan"
}
},
"definitions": {
"meta": {
Expand Down Expand Up @@ -155,5 +162,11 @@
"displayName": "Keyboard"
},
"isSuppressNavigable": {}
},
"formulas": {
"meta": {
"displayName": "Formulas"
},
"isAllowFormula": {}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"_config_": {
"codeSrc": "column-options.AUTO.json"
"codeSrc": "column-options.AUTO.json",
"validate": true,
"undocumentedProperties": {
"pivotKeys": "Internal use only, doc comment says 'Never set this'",
"pivotValueColumn": "Internal use only, doc comment says 'Never set this'",
"pivotTotalColumnIds": "Internal use only, doc comment says 'Never set this'",
"rowSpan": "Old API, not deprecated, but not encouraged either"
}
},
"columns": {
"meta": {
Expand Down Expand Up @@ -466,6 +473,8 @@
"cellEditorPopup": {},
"cellEditorPopupPosition": {},
"singleClickEdit": {},
"groupRowEditable": {},
"groupRowValueSetter": {},
"useValueParserForImport": {
"more": {
"name": "Using Value Parsers with Other Grid Features",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"_config_": {
"codeSrc": "grid-api.AUTO.json"
"codeSrc": "grid-api.AUTO.json",
"validate": true,
"undocumentedProperties": {
"sortChanged": "TODO: undocumented property, to resolve in AG-16879",
"flushAllAnimationFrames": "TODO: undocumented property, to resolve in AG-16879",
"getColumnDef": "TODO: undocumented property, to resolve in AG-16879",
"filterChanged": "TODO: undocumented property, to resolve in AG-16879",
"getInfiniteRowCount": "TODO: undocumented property, to resolve in AG-16879",
"flushServerSideAsyncTransactions": "TODO: undocumented property, to resolve in AG-16879",
"dispatchEvent": "TODO: undocumented property, to resolve in AG-16879"
}
},
"gridOptions": {
"meta": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{
"_config_": {
"codeSrc": "grid-options.AUTO.json"
"codeSrc": "grid-options.AUTO.json",
"validate": true,
"onlyEvents": true,
"undocumentedProperties": {
"bulkEditingStarted": "TODO: undocumented property, to resolve in AG-16879",
"bulkEditingStopped": "TODO: undocumented property, to resolve in AG-16879",
"dragCancelled": "TODO: undocumented property, to resolve in AG-16879",
"rowResizeStarted": "TODO: undocumented property, to resolve in AG-16879",
"rowResizeEnded": "TODO: undocumented property, to resolve in AG-16879"
}
},
"accessories": {
"meta": {
Expand Down
Loading
Loading