Skip to content

Conversation

@imamatory
Copy link
Contributor

@imamatory imamatory commented May 27, 2025

PR Details

The documentation content for certain types in the input XSD is missing due to parsing issues. This affects the accuracy and completeness of the generated documentation.

Description

Given XSD:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Blog">
        <xs:annotation>
            <xs:documentation>Blog content</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Post" maxOccurs="1000">
                    <xs:annotation>
                        <xs:documentation>Posts in blog</xs:documentation>
                    </xs:annotation>
                </xs:element>
            </xs:sequence>
            <xs:attribute name="CreatedAt" type="xs:date" use="required">
                <xs:annotation>
                    <xs:documentation>Date of creation</xs:documentation>
                </xs:annotation>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
</xs:schema>

xgen generate go types (note the comment before struct):

// Code generated by xgen. DO NOT EDIT.

package schema

// Blog ...
type Blog struct {
	CreatedAtAttr string  `xml:"CreatedAt,attr"`
	Post          []*Post `xml:"Post"`
}

// Post is Date of creation
type Post []*Post

While the expected result:

// Code generated by xgen. DO NOT EDIT.

package schema

// Blog is Blog content
type Blog struct {
	CreatedAtAttr string  `xml:"CreatedAt,attr"`
	Post          []*Post `xml:"Post"`
}

// Post is Date of creation
type Post []*Post

Motivation and Context

This fix helps to transform a 3k+ XSD file and keep documentation to avoid tons of manual work.

How Has This Been Tested

All existing tests passed.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@xuri xuri added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 2, 2025
xuri added a commit to xuri/xsd that referenced this pull request Jun 6, 2025
@codecov
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.50%. Comparing base (d0691b7) to head (b0b6f8f).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #92      +/-   ##
==========================================
- Coverage   83.57%   81.50%   -2.07%     
==========================================
  Files          36       36              
  Lines        1534     1817     +283     
==========================================
+ Hits         1282     1481     +199     
- Misses        159      243      +84     
  Partials       93       93              
Flag Coverage Δ
unittests 81.50% <100.00%> (-2.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Owner

@xuri xuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your contribution.

@xuri xuri merged commit 68e8885 into xuri:master Jun 7, 2025
8 of 14 checks passed
@imamatory imamatory deleted the fix/doc branch June 7, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants