]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
libvaladoc: reorder @param
authorFlorian Brosch <flo.brosch@gmail.com>
Fri, 6 Jan 2012 17:40:00 +0000 (18:40 +0100)
committerFlorian Brosch <flo.brosch@gmail.com>
Fri, 6 Jan 2012 17:40:00 +0000 (18:40 +0100)
src/libvaladoc/html/htmlrenderer.vala
src/libvaladoc/taglets/tagletparam.vala

index d0ea807cbd307c2417377190983d0c885ee4fffc..0655ce02b99702058600de12269b47921d18b59c 100755 (executable)
@@ -115,6 +115,38 @@ public class Valadoc.Html.HtmlRenderer : ContentRenderer {
                element.accept_children (this);
 
                taglets = element.find_taglets ((Api.Node) _container, typeof (Taglets.Param));
+               taglets.sort ((_a, _b) => {
+                       Taglets.Param a = _a as Taglets.Param;
+                       Taglets.Param b = _b as Taglets.Param;
+
+                       if (a.position < 0 && b.position < 0) {
+                               int cmp = a.parameter_name.ascii_casecmp (b.parameter_name);
+                               if (cmp == 0) {
+                                       return 0;
+                               }
+
+                               if (a.parameter_name == "...") {
+                                       return 1;
+                               }
+
+                               if (b.parameter_name == "...") {
+                                       return -1;
+                               }
+
+                               return cmp;
+                       }
+
+                       if (a.position < 0) {
+                               return 1;
+                       }
+
+                       if (b.position < 0) {
+                               return -1;
+                       }
+
+                       return a.position - b.position;
+               });
+
                write_taglets (
                        () => {
                                writer.start_tag ("h2", {"class", "main_title"}).text ("Parameters:").end_tag ("h2");
index db0d962c355961bdebb8a2e17c878fa8ca0fd98e..6dfb235ef2208d8363f68dedde56dcded10cca81 100755 (executable)
@@ -27,7 +27,9 @@ using Valadoc.Content;
 public class Valadoc.Taglets.Param : InlineContent, Taglet, Block {
        public string parameter_name { internal set; get; }
 
-       public Api.Symbol? parameter { private set; get; }
+       public weak Api.Symbol? parameter { private set; get; }
+
+       public int position { private set; get; default = -1; }
 
        public Rule? get_parser_rule (Rule run_rule) {
                return Rule.seq ({
@@ -40,7 +42,6 @@ public class Valadoc.Taglets.Param : InlineContent, Taglet, Block {
 
        public override void check (Api.Tree api_root, Api.Node container, ErrorReporter reporter, Settings settings) {
                // Check for the existence of such a parameter
-
                this.parameter = null;
 
                if (parameter_name == "...") {
@@ -48,16 +49,22 @@ public class Valadoc.Taglets.Param : InlineContent, Taglet, Block {
                        foreach (Api.Node param in params) {
                                if (((Api.FormalParameter) param).ellipsis) {
                                        this.parameter = (Api.Symbol) param;
+                                       this.position = params.size - 1;
                                        break;
                                }
                        }
                } else {
                        Gee.List<Api.Node> params = container.get_children_by_types ({Api.NodeType.FORMAL_PARAMETER, Api.NodeType.TYPE_PARAMETER}, false);
+                       int pos = 0;
+
                        foreach (Api.Node param in params) {
                                if (param.name == parameter_name) {
                                        this.parameter = (Api.Symbol) param;
+                                       this.position = pos;
                                        break;
                                }
+
+                               pos++;
                        }
                }