Skip to content

Commit

Permalink
Merge pull request #138 from k1LoW/md-remove-duplicate-relations
Browse files Browse the repository at this point in the history
Remove duplicate relation links
  • Loading branch information
k1LoW authored Sep 5, 2019
2 parents 8ae6fc2 + 36e5f24 commit 5aebddc
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions output/md/md.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,22 @@ func makeTableTemplateData(t *schema.Table, adjust bool) map[string]interface{}
}
for _, c := range t.Columns {
childRelations := []string{}
cEncountered := map[string]bool{}
for _, r := range c.ChildRelations {
if _, ok := cEncountered[r.Table.Name]; ok {
continue
}
childRelations = append(childRelations, fmt.Sprintf("[%s](%s.md)", r.Table.Name, r.Table.Name))
cEncountered[r.Table.Name] = true
}
parentRelations := []string{}
pEncountered := map[string]bool{}
for _, r := range c.ParentRelations {
if _, ok := pEncountered[r.ParentTable.Name]; ok {
continue
}
parentRelations = append(parentRelations, fmt.Sprintf("[%s](%s.md)", r.ParentTable.Name, r.ParentTable.Name))
pEncountered[r.ParentTable.Name] = true
}
data := []string{
c.Name,
Expand Down

0 comments on commit 5aebddc

Please sign in to comment.