diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2020-08-24 13:14:09 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2020-08-24 13:58:18 +0200 |
commit | a08d5ced8dab35174a79639b7450fd7b462bf419 (patch) | |
tree | ef359531d9244362606482f0e84faae8e99f6bf4 /libvaladoc | |
parent | 1d54f3e6797c50f2e115fe5e346560050956d224 (diff) | |
download | vala-a08d5ced8dab35174a79639b7450fd7b462bf419.tar.gz |
libvaladoc/girimporter: Improve parse_symbol_doc() and don't use parse_doc()
Diffstat (limited to 'libvaladoc')
-rw-r--r-- | libvaladoc/importer/girdocumentationimporter.vala | 68 |
1 files changed, 25 insertions, 43 deletions
diff --git a/libvaladoc/importer/girdocumentationimporter.vala b/libvaladoc/importer/girdocumentationimporter.vala index ae3e9948b..7be872f22 100644 --- a/libvaladoc/importer/girdocumentationimporter.vala +++ b/libvaladoc/importer/girdocumentationimporter.vala @@ -314,52 +314,28 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter { private Api.GirSourceComment? parse_symbol_doc () { Api.GirSourceComment? comment = null; + Api.SourceComment? doc_deprecated = null; + Api.SourceComment? doc_version = null; + Api.SourceComment? doc_stability = null; - if (reader.name == "doc") { - start_element ("doc"); - next (); - - - if (current_token == Vala.MarkupTokenType.TEXT) { - comment = new Api.GirSourceComment (reader.content, file, begin.line, - begin.column, end.line, end.column); + while (current_token == Vala.MarkupTokenType.START_ELEMENT) { + if (reader.name == "doc") { + start_element ("doc"); next (); - } - end_element ("doc"); - } - - while (true) { - if (reader.name == "doc-deprecated") { - Api.SourceComment? doc_deprecated = parse_doc ("doc-deprecated"); - if (doc_deprecated != null) { - if (comment == null) { - comment = new Api.GirSourceComment ("", file, begin.line, end.line, - begin.line, end.line); - } - - comment.deprecated_comment = doc_deprecated; + if (current_token == Vala.MarkupTokenType.TEXT) { + comment = new Api.GirSourceComment (reader.content, file, begin.line, + begin.column, end.line, end.column); + next (); } - } else if (reader.name == "doc-version") { - Api.SourceComment? doc_version = parse_doc ("doc-version"); - if (doc_version != null) { - if (comment == null) { - comment = new Api.GirSourceComment ("", file, begin.line, end.line, - begin.line, end.line); - } - comment.version_comment = doc_version; - } + end_element ("doc"); + } else if (reader.name == "doc-deprecated") { + doc_deprecated = parse_doc ("doc-deprecated"); + } else if (reader.name == "doc-version") { + doc_version = parse_doc ("doc-version"); } else if (reader.name == "doc-stability") { - Api.SourceComment? doc_stability = parse_doc ("doc-stability"); - if (doc_stability != null) { - if (comment == null) { - comment = new Api.GirSourceComment ("", file, begin.line, end.line, - begin.line, end.line); - } - - comment.stability_comment = doc_stability; - } + doc_stability = parse_doc ("doc-stability"); } else if (reader.name == "source-position") { skip_element (); } else if (reader.name == "attribute") { @@ -369,6 +345,12 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter { } } + if (comment != null) { + comment.deprecated_comment = doc_deprecated; + comment.version_comment = doc_version; + comment.stability_comment = doc_stability; + } + return comment; } @@ -435,7 +417,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter { start_element ("return-value"); next (); - comment = parse_doc (); + comment = parse_symbol_doc (); parse_type (out array_length_ret); @@ -468,7 +450,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter { } next (); - comment = parse_doc (); + comment = parse_symbol_doc (); if (reader.name == "varargs") { start_element ("varargs"); @@ -712,7 +694,7 @@ public class Valadoc.Importer.GirDocumentationImporter : DocumentationImporter { string instance_param_name = reader.get_attribute ("name"); next (); - Api.SourceComment? param_comment = parse_doc (); + Api.SourceComment? param_comment = parse_symbol_doc (); parse_type (null); end_element ("instance-parameter"); |