Skip to content

Commit 7165708

Browse files
Copilotaabidsofi19
andcommitted
Remove CreateRelationshipsMetadataAndCreateSVGsForMDXStyle function as only markdown is published
Co-authored-by: aabidsofi19 <65964225+aabidsofi19@users.noreply.github.com>
1 parent a5c6bf8 commit 7165708

File tree

2 files changed

+0
-110
lines changed

2 files changed

+0
-110
lines changed

registry/component.go

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -375,68 +375,6 @@ func CreateRelationshipsMetadata(model ModelCSV, relationships []RelationshipCSV
375375

376376
}
377377

378-
// CreateRelationshipsMetadataAndCreateSVGsForMDXStyle creates relationship metadata and writes SVGs for MDX style docs
379-
func CreateRelationshipsMetadataAndCreateSVGsForMDXStyle(model ModelCSV, relationships []RelationshipCSV, path, svgDir string) (string, error) {
380-
err := os.MkdirAll(filepath.Join(path, svgDir), 0777)
381-
if err != nil {
382-
return "", err
383-
}
384-
relationshipMetadata := `[`
385-
for idx, relnship := range relationships {
386-
relationshipTemplate := `
387-
{
388-
"type": "%s",
389-
"kind": "%s",
390-
"colorIcon": "%s",
391-
"whiteIcon": "%s",
392-
"description": "%s"
393-
}`
394-
395-
// add comma if not last relationship
396-
if idx != len(relationships)-1 {
397-
relationshipTemplate += ","
398-
}
399-
400-
relnshipName := utils.FormatName(manifests.FormatToReadableString(fmt.Sprintf("%s-%s", relnship.KIND, relnship.SubType)))
401-
colorIconDir := filepath.Join(svgDir, relnshipName, "icons", "color")
402-
whiteIconDir := filepath.Join(svgDir, relnshipName, "icons", "white")
403-
404-
relationshipMetadata += fmt.Sprintf(relationshipTemplate, relnship.Type, relnship.KIND, fmt.Sprintf("%s/%s-color.svg", colorIconDir, relnshipName), fmt.Sprintf("%s/%s-white.svg", whiteIconDir, relnshipName), relnship.Description)
405-
406-
// Get SVGs for relationship
407-
colorSVG, whiteSVG := getSVGForRelationship(model, relnship)
408-
409-
// Only create directories and write SVGs if they exist
410-
if colorSVG != "" {
411-
// create color svg dir
412-
err = os.MkdirAll(filepath.Join(path, colorIconDir), 0777)
413-
if err != nil {
414-
return "", err
415-
}
416-
err = utils.WriteToFile(filepath.Join(path, colorIconDir, relnshipName+"-color.svg"), colorSVG)
417-
if err != nil {
418-
return "", err
419-
}
420-
}
421-
422-
if whiteSVG != "" {
423-
// create white svg dir
424-
err = os.MkdirAll(filepath.Join(path, whiteIconDir), 0777)
425-
if err != nil {
426-
return "", err
427-
}
428-
err = utils.WriteToFile(filepath.Join(path, whiteIconDir, relnshipName+"-white.svg"), whiteSVG)
429-
if err != nil {
430-
return "", err
431-
}
432-
}
433-
}
434-
435-
relationshipMetadata += `]`
436-
437-
return relationshipMetadata, nil
438-
}
439-
440378
// CreateRelationshipsMetadataAndCreateSVGsForMDStyle creates relationship metadata and writes SVGs for MD style docs
441379
func CreateRelationshipsMetadataAndCreateSVGsForMDStyle(model ModelCSV, relationships []RelationshipCSV, path, svgDir string) (string, error) {
442380
err := os.MkdirAll(filepath.Join(path), 0777)

registry/component_test.go

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -165,54 +165,6 @@ func TestGetSVGForRelationship(t *testing.T) {
165165
}
166166
}
167167

168-
func TestCreateRelationshipsMetadataAndCreateSVGsForMDXStyle(t *testing.T) {
169-
// Create a temporary directory for the test
170-
tmpDir, err := os.MkdirTemp("", "relationship-svg-test")
171-
assert.NoError(t, err)
172-
defer os.RemoveAll(tmpDir)
173-
174-
model := ModelCSV{
175-
SVGColor: "<svg>model-color</svg>",
176-
SVGWhite: "<svg>model-white</svg>",
177-
}
178-
179-
relationships := []RelationshipCSV{
180-
{
181-
KIND: "edge",
182-
SubType: "binding",
183-
Type: "hierarchical",
184-
Description: "Test relationship",
185-
Styles: `{"svgColor": "<svg>rel-color</svg>", "svgWhite": "<svg>rel-white</svg>"}`,
186-
},
187-
}
188-
189-
svgDir := "icons"
190-
metadata, err := CreateRelationshipsMetadataAndCreateSVGsForMDXStyle(model, relationships, tmpDir, svgDir)
191-
assert.NoError(t, err)
192-
assert.NotEmpty(t, metadata)
193-
194-
// Verify metadata structure
195-
assert.Contains(t, metadata, "edge")
196-
assert.Contains(t, metadata, "hierarchical")
197-
assert.Contains(t, metadata, "Test relationship")
198-
199-
// Verify SVG files were created - derive name the same way as implementation
200-
rel := relationships[0]
201-
relnshipName := utils.FormatName(manifests.FormatToReadableString(fmt.Sprintf("%s-%s", rel.KIND, rel.SubType)))
202-
colorSVGPath := filepath.Join(tmpDir, svgDir, relnshipName, "icons", "color", relnshipName+"-color.svg")
203-
whiteSVGPath := filepath.Join(tmpDir, svgDir, relnshipName, "icons", "white", relnshipName+"-white.svg")
204-
205-
// Check color SVG exists and has correct content
206-
colorContent, err := os.ReadFile(colorSVGPath)
207-
assert.NoError(t, err)
208-
assert.Equal(t, "<svg>rel-color</svg>", string(colorContent))
209-
210-
// Check white SVG exists and has correct content
211-
whiteContent, err := os.ReadFile(whiteSVGPath)
212-
assert.NoError(t, err)
213-
assert.Equal(t, "<svg>rel-white</svg>", string(whiteContent))
214-
}
215-
216168
func TestCreateRelationshipsMetadataAndCreateSVGsForMDStyle(t *testing.T) {
217169
// Create a temporary directory for the test
218170
tmpDir, err := os.MkdirTemp("", "relationship-svg-test-md")

0 commit comments

Comments
 (0)