Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash parsing enum #972

Closed
ianpartridge opened this issue May 15, 2018 · 2 comments · Fixed by #975
Closed

Crash parsing enum #972

ianpartridge opened this issue May 15, 2018 · 2 comments · Fixed by #975
Labels

Comments

@ianpartridge
Copy link

Jazzy 0.9.2 and later fails to generate docs for the following enum:

public enum Test: String {
    case broken = "\u{001B}"
}

Callstack:

Traceback (most recent call last):
	26: from /usr/local/bin/jazzy:23:in `<main>'
	25: from /usr/local/bin/jazzy:23:in `load'
	24: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/bin/jazzy:15:in `<top (required)>'
	23: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:77:in `build'
	22: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:145:in `build_docs_for_sourcekitten_output'
	21: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:795:in `parse'
	20: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `make_source_declarations'
	19: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `each'
	18: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:437:in `block in make_source_declarations'
	17: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `make_source_declarations'
	16: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `each'
	15: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:484:in `block in make_source_declarations'
	14: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:420:in `make_substructure'
	13: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `make_source_declarations'
	12: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `each'
	11: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:458:in `block in make_source_declarations'
	10: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `make_source_declarations'
	 9: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `each'
	 8: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:483:in `block in make_source_declarations'
	 7: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:322:in `make_doc_info'
	 6: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:395:in `make_swift_declaration'
	 5: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:340:in `xml_to_text'
	 4: from /usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:340:in `new'
	 3: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/document.rb:45:in `initialize'
	 2: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/document.rb:288:in `build'
	 1: from /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/parsers/treeparser.rb:21:in `parse'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/parsers/treeparser.rb:96:in `rescue in parse': #<RuntimeError: Illegal character "\e" in raw string "case broken = &quot;quot;"> (REXML::ParseException)
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/text.rb:139:in `block in check'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/text.rb:135:in `each'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/text.rb:135:in `check'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/text.rb:121:in `initialize'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/parsers/treeparser.rb:47:in `new'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/parsers/treeparser.rb:47:in `parse'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/document.rb:288:in `build'
/usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/rexml/document.rb:45:in `initialize'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:340:in `new'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:340:in `xml_to_text'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:395:in `make_swift_declaration'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:322:in `make_doc_info'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:483:in `block in make_source_declarations'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `each'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `make_source_declarations'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:458:in `block in make_source_declarations'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `each'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `make_source_declarations'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:420:in `make_substructure'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:484:in `block in make_source_declarations'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `each'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `make_source_declarations'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:437:in `block in make_source_declarations'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `each'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:435:in `make_source_declarations'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/sourcekitten.rb:795:in `parse'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:145:in `build_docs_for_sourcekitten_output'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/lib/jazzy/doc_builder.rb:77:in `build'
/usr/local/lib/ruby/gems/2.5.0/gems/jazzy-0.9.3/bin/jazzy:15:in `<top (required)>'
/usr/local/bin/jazzy:23:in `load'
/usr/local/bin/jazzy:23:in `<main>'
...
Illegal character "\e" in raw string "case broken = &quot;quot;"
Line: 1
Position: 54
Last 80 unconsumed characters:
</Declaration>
@johnfairh
Copy link
Collaborator

Foundation's JSONSerialization and Ruby's JSON parser aren't round-tripping perfectly, but I think that can be put down to SourceKit producing bad XML: Xcode quick help also fails on the 'broken' case in the example.

This is a very fragile chain... I think the best thing for jazzy is to let the XML parse fail and safely fall back to the parsed declaration.

SR-7698 to fix the Swift bug.

@johnfairh johnfairh added the bug label May 16, 2018
@jpsim
Copy link
Collaborator

jpsim commented May 18, 2018

Thanks for the great analysis @johnfairh! I agree with your proposed solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants