@mui/internal-docs-infra 0.12.1-canary.30 → 0.12.1-canary.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-docs-infra",
3
- "version": "0.12.1-canary.30",
3
+ "version": "0.12.1-canary.32",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI Infra - internal documentation creation tools.",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "@orama/stopwords": "^3.1.18",
40
40
  "@wooorm/starry-night": "^3.10.0",
41
41
  "autoprefixer": "^10.5.4",
42
- "chalk": "^5.6.2",
42
+ "chalk": "^6.0.0",
43
43
  "clipboard-copy": "^4.0.1",
44
44
  "es-toolkit": "^1.49.0",
45
45
  "fflate": "^0.8.3",
@@ -804,5 +804,5 @@
804
804
  "bin": {
805
805
  "docs-infra": "./cli/index.mjs"
806
806
  },
807
- "gitSha": "572e3cf0688164ad834cee4c5d64d91d2bce1d68"
807
+ "gitSha": "14edbfe69366e1a1e506acaf77d33186d6e4090c"
808
808
  }
@@ -76,6 +76,16 @@ function extractInlineCodeOrText(node) {
76
76
  return '';
77
77
  }
78
78
 
79
+ /** Extract inline-code values from mdast phrasing content. */
80
+ function extractInlineCodeValues(nodes) {
81
+ return nodes.flatMap(node => {
82
+ if (node.type === 'inlineCode') {
83
+ return node.value;
84
+ }
85
+ return 'children' in node ? extractInlineCodeValues(node.children) : [];
86
+ });
87
+ }
88
+
79
89
  /**
80
90
  * A target for batch HAST conversion: a setter to assign the result and the mdast nodes to convert.
81
91
  */
@@ -533,6 +543,9 @@ export async function parseTypesMarkdown(content, ordering) {
533
543
  const allTypes = [];
534
544
  const descriptionTargets = [];
535
545
  const externalTypes = {};
546
+ const parsedVariantTypes = {};
547
+ const typeNameMap = {};
548
+ const parsedVariantTypeNameMapKeys = {};
536
549
 
537
550
  // Track current context
538
551
  let currentH3Name = null;
@@ -553,6 +566,7 @@ export async function parseTypesMarkdown(content, ordering) {
553
566
  let lastParamExampleName = null;
554
567
  let lastPropReferencesName = null;
555
568
  let lastParamReferencesName = null;
569
+ let metadataSection = null;
556
570
 
557
571
  // Helper to flush the current section
558
572
  const flushSection = () => {
@@ -697,6 +711,12 @@ export async function parseTypesMarkdown(content, ordering) {
697
711
  if (node.type === 'heading' && node.depth === 2) {
698
712
  flushSection();
699
713
  const text = extractText(node.children);
714
+ metadataSection = null;
715
+ if (text === 'Export Groups') {
716
+ metadataSection = 'export-groups';
717
+ } else if (text === 'Canonical Types') {
718
+ metadataSection = 'canonical-types';
719
+ }
700
720
  if (text === 'External Types') {
701
721
  inExternalTypes = true;
702
722
  } else if (text === 'Additional Types') {
@@ -712,6 +732,7 @@ export async function parseTypesMarkdown(content, ordering) {
712
732
  if (node.type === 'heading' && node.depth === 3) {
713
733
  flushSection();
714
734
  inExternalTypes = false;
735
+ metadataSection = null;
715
736
  currentH3Name = extractText(node.children);
716
737
  continue;
717
738
  }
@@ -722,6 +743,36 @@ export async function parseTypesMarkdown(content, ordering) {
722
743
  continue;
723
744
  }
724
745
 
746
+ // Handle generated metadata lists
747
+ if (node.type === 'list' && metadataSection) {
748
+ for (const item of node.children) {
749
+ const children = item.children.flatMap(child => child.type === 'paragraph' ? child.children : []);
750
+ const separatorIndex = children.findIndex(child => child.type === 'text' && child.value.includes(':'));
751
+ const namesBeforeSeparator = extractInlineCodeValues(children.slice(0, separatorIndex === -1 ? children.length : separatorIndex));
752
+ const namesAfterSeparator = separatorIndex === -1 ? [] : extractInlineCodeValues(children.slice(separatorIndex + 1));
753
+ if (metadataSection === 'export-groups') {
754
+ const variantName = namesBeforeSeparator[0];
755
+ if (variantName) {
756
+ parsedVariantTypes[variantName] = separatorIndex === -1 ? [variantName] : namesAfterSeparator;
757
+ }
758
+ } else {
759
+ const [canonicalName, ...variants] = namesBeforeSeparator;
760
+ if (!canonicalName || separatorIndex === -1) {
761
+ continue;
762
+ }
763
+ for (const flatName of namesAfterSeparator) {
764
+ typeNameMap[flatName] = canonicalName;
765
+ }
766
+ for (const variant of variants) {
767
+ const keys = parsedVariantTypeNameMapKeys[variant] ?? [];
768
+ keys.push(...namesAfterSeparator);
769
+ parsedVariantTypeNameMapKeys[variant] = keys;
770
+ }
771
+ }
772
+ }
773
+ continue;
774
+ }
775
+
725
776
  // Handle code blocks
726
777
  if (node.type === 'code') {
727
778
  if (inExternalTypes && currentExternalTypeName) {
@@ -833,97 +884,8 @@ export async function parseTypesMarkdown(content, ordering) {
833
884
 
834
885
  // Flush the last section
835
886
  flushSection();
836
-
837
- // Parse metadata from human-readable sections instead of JSON comments
838
- // The new format uses "## Export Groups" and "## Canonical Types" sections
839
-
840
- // Parse Export Groups section
841
- // Format: - `VariantName`: `Type1`, `Type2` (or just `- VariantName` if key equals single value)
842
- let variantTypes = null;
843
- const exportGroupsMatch = content.match(/## Export Groups\n([\s\S]*?)(?=\n## |$)/);
844
- if (exportGroupsMatch) {
845
- variantTypes = {};
846
- const lines = exportGroupsMatch[1].trim().split('\n');
847
- for (const line of lines) {
848
- // Match: - `VariantName`: `Type1`, `Type2` OR - `VariantName`
849
- const withValuesMatch = line.match(/^- `([^`]+)`:\s*(.+)$/);
850
- const singleMatch = line.match(/^- `([^`]+)`$/);
851
- if (withValuesMatch) {
852
- const variantName = withValuesMatch[1];
853
- // Extract all backtick-wrapped values
854
- const values = withValuesMatch[2].match(/`([^`]+)`/g);
855
- variantTypes[variantName] = values ? values.map(v => v.slice(1, -1)) : [];
856
- } else if (singleMatch) {
857
- // Key equals value - the variant name IS the single type
858
- const variantName = singleMatch[1];
859
- variantTypes[variantName] = [variantName];
860
- }
861
- }
862
- // Only keep variantTypes if we found entries
863
- if (Object.keys(variantTypes).length === 0) {
864
- variantTypes = null;
865
- }
866
- }
867
-
868
- // Parse Canonical Types section
869
- // Format: - `CanonicalName` (`Variant1`, `Variant2`): `FlatName1`, `FlatName2`
870
- // OR: - `CanonicalName`: `FlatName1`, `FlatName2` (no variant annotation)
871
- const typeNameMap = {};
872
- let variantTypeNameMapKeys = null;
873
- const canonicalTypesMatch = content.match(/## Canonical Types\n([\s\S]*?)(?=\n## |$)/);
874
- if (canonicalTypesMatch) {
875
- variantTypeNameMapKeys = {};
876
- const lines = canonicalTypesMatch[1].trim().split('\n');
877
- for (const line of lines) {
878
- // Match: - `CanonicalName` (`Variant1`, `Variant2`): `FlatName1`, `FlatName2`
879
- // OR: - `CanonicalName`: `FlatName1`, `FlatName2`
880
- const withVariantMatch = line.match(/^- `([^`]+)`\s+\(([^)]+)\):\s*(.+)$/);
881
- const withoutVariantMatch = line.match(/^- `([^`]+)`:\s*(.+)$/);
882
- let canonicalName;
883
- let flatNamesStr;
884
- let variants = [];
885
- if (withVariantMatch) {
886
- canonicalName = withVariantMatch[1];
887
- // Extract variants from parentheses
888
- const variantStr = withVariantMatch[2];
889
- const variantMatches = variantStr.match(/`([^`]+)`/g);
890
- variants = variantMatches ? variantMatches.map(v => v.slice(1, -1)) : [];
891
- flatNamesStr = withVariantMatch[3];
892
- } else if (withoutVariantMatch) {
893
- canonicalName = withoutVariantMatch[1];
894
- flatNamesStr = withoutVariantMatch[2];
895
- // No variant annotation - applies to all variants
896
- } else {
897
- continue;
898
- }
899
-
900
- // Extract all flat names
901
- const flatNameMatches = flatNamesStr.match(/`([^`]+)`/g);
902
- const flatNames = flatNameMatches ? flatNameMatches.map(v => v.slice(1, -1)) : [];
903
-
904
- // Build typeNameMap (flat name -> canonical name)
905
- for (const flatName of flatNames) {
906
- typeNameMap[flatName] = canonicalName;
907
- }
908
-
909
- // Build variantTypeNameMapKeys (variant -> list of keys)
910
- // If no variants specified, we don't track variant-specific keys
911
- if (variants.length > 0) {
912
- for (const variant of variants) {
913
- if (!variantTypeNameMapKeys[variant]) {
914
- variantTypeNameMapKeys[variant] = [];
915
- }
916
- for (const flatName of flatNames) {
917
- variantTypeNameMapKeys[variant].push(flatName);
918
- }
919
- }
920
- }
921
- }
922
- // Only keep variantTypeNameMapKeys if we found entries
923
- if (Object.keys(variantTypeNameMapKeys).length === 0) {
924
- variantTypeNameMapKeys = null;
925
- }
926
- }
887
+ const variantTypes = Object.keys(parsedVariantTypes).length > 0 ? parsedVariantTypes : null;
888
+ const variantTypeNameMapKeys = Object.keys(parsedVariantTypeNameMapKeys).length > 0 ? parsedVariantTypeNameMapKeys : null;
927
889
 
928
890
  // Convert all description mdast nodes to HAST in parallel
929
891
  await convertDescriptions(descriptionTargets);