]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add warning & note tags
authorFlorian Brosch <flo.brosch@gmail.com>
Thu, 5 Jan 2012 02:24:02 +0000 (03:24 +0100)
committerFlorian Brosch <flo.brosch@gmail.com>
Thu, 5 Jan 2012 02:24:02 +0000 (03:24 +0100)
icons/Makefile.am
icons/tip.png [new file with mode: 0644]
src/doclets/gtkdoc/commentconverter.vala
src/libvaladoc/Makefile.am
src/libvaladoc/content/contentfactory.vala
src/libvaladoc/content/contentvisitor.vala
src/libvaladoc/content/note.vala [new file with mode: 0755]
src/libvaladoc/content/warning.vala [new file with mode: 0755]
src/libvaladoc/documentation/documentationparser.vala
src/libvaladoc/html/htmlmarkupwriter.vala
src/libvaladoc/html/htmlrenderer.vala

index 5869bff058414e3df4c4eb4c7960a423540dc63b..4859e248bd414bea43a6d0435ac1522a3c85afc3 100644 (file)
@@ -5,6 +5,7 @@ iconsdir = $(datadir)/valadoc/icons
 
 
 dist_icons_DATA =        \
+       tip.png              \
        warning.png          \
        abstractclass.png    \
        abstractmethod.png   \
diff --git a/icons/tip.png b/icons/tip.png
new file mode 100644 (file)
index 0000000..6ccf512
Binary files /dev/null and b/icons/tip.png differ
index a0c3372ce3a06d3eae345db9991afdc9687e5962..e10b8aa3a534016aadd24a7c32250a9a4c5c4490 100755 (executable)
@@ -172,7 +172,19 @@ public class Gtkdoc.CommentConverter : ContentVisitor {
                        current_builder.append ("</para>");
                }
        }
-  
+
+       public override void visit_warning (Warning element) {
+               current_builder.append ("<warning>");
+               element.accept_children (this);
+               current_builder.append ("</warning>");
+       }
+
+       public override void visit_note (Note element) {
+               current_builder.append ("<note>");
+               element.accept_children (this);
+               current_builder.append ("</note>");
+       }
+
        public override void visit_page (Page page) {
                page.accept_children (this);
        }
index 310a3dbd132b735796b320bbf70dfb08656bf899..fe3115c8e1dabbc6c6e8e1efa3c682cee3d7f0c1 100755 (executable)
@@ -26,11 +26,13 @@ libvaladoc_la_VALASOURCES = \
        moduleloader.vala \
        settings.vala \
        markupwriter.vala \
+       gtkdocmarkupwriter.vala \
        devhelp-markupwriter.vala \
        ctyperesolver.vala \
        markupsourcelocation.vala \
        markuptokentype.vala \
        markupreader.vala \
+       gtkdocrenderer.vala \
        documentation/commentscanner.vala \
        documentation/documentation.vala \
        documentation/documentationparser.vala \
@@ -103,6 +105,8 @@ libvaladoc_la_VALASOURCES = \
        content/listitem.vala \
        content/page.vala \
        content/paragraph.vala \
+       content/warning.vala \
+       content/note.vala \
        content/resourcelocator.vala \
        content/run.vala \
        content/sourcecode.vala \
index 55c44f7ac03a9c0bc5754fcc5cb1cfa16eb4931c..19cf41be21ea4b05f396131e384ba80657746fb3 100755 (executable)
@@ -76,6 +76,13 @@ public class Valadoc.Content.ContentFactory : Object {
                return (Paragraph) configure (new Paragraph ());
        }
 
+       public Warning create_warning () {
+               return (Warning) configure (new Warning ());
+       }
+       public Note create_note () {
+               return (Note) configure (new Note ());
+       }
+
        public Run create_run (Run.Style style) {
                return (Run) configure (new Run (style));
        }
index bacffc3ddf017a573f03036f09e741bef35a93b2..3eb3a4b3d4ce57f3290931b8bcdf7247fbab0805 100755 (executable)
@@ -52,6 +52,12 @@ public abstract class Valadoc.Content.ContentVisitor : Object {
        public virtual void visit_paragraph (Paragraph element) {
        }
 
+       public virtual void visit_warning (Warning element) {
+       }
+
+       public virtual void visit_note (Note element) {
+       }
+
        public virtual void visit_page (Page element) {
        }
 
diff --git a/src/libvaladoc/content/note.vala b/src/libvaladoc/content/note.vala
new file mode 100755 (executable)
index 0000000..d2b16c5
--- /dev/null
@@ -0,0 +1,40 @@
+/* note.vala
+ *
+ * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Didier 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+
+public class Valadoc.Content.Note : BlockContent, Block {
+       internal Note () {
+               base ();
+       }
+
+       public override void check (Api.Tree api_root, Api.Node container, ErrorReporter reporter, Settings settings) {
+               // Check inline content
+               base.check (api_root, container, reporter, settings);
+       }
+
+       public override void accept (ContentVisitor visitor) {
+               visitor.visit_note (this);
+       }
+}
+
diff --git a/src/libvaladoc/content/warning.vala b/src/libvaladoc/content/warning.vala
new file mode 100755 (executable)
index 0000000..e848c43
--- /dev/null
@@ -0,0 +1,40 @@
+/* warning.vala
+ *
+ * Copyright (C) 2008-2009 Florian Brosch, Didier Villevalois
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ *
+ * Author:
+ *     Didier 'Ptitjes Villevalois <ptitjes@free.fr>
+ */
+
+using Gee;
+
+
+public class Valadoc.Content.Warning : BlockContent, Block {
+       internal Warning () {
+               base ();
+       }
+
+       public override void check (Api.Tree api_root, Api.Node container, ErrorReporter reporter, Settings settings) {
+               // Check inline content
+               base.check (api_root, container, reporter, settings);
+       }
+
+       public override void accept (ContentVisitor visitor) {
+               visitor.visit_warning (this);
+       }
+}
+
index b2a96f02525030f1d3fd61cf360cd228eb47cd24..1b29698dd44c52ccd6f39c69a48d465f028c45bc 100755 (executable)
@@ -499,6 +499,50 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                                }
                        });
 
+               Rule warning =
+                       Rule.seq ({
+                               TokenType.str ("Warning:"),
+                               optional_invisible_spaces,
+                               Rule.many ({
+                                       Rule.seq({optional_invisible_spaces, run}),
+                                       TokenType.EOL.action (() => { add_content_space (); })
+                               })
+                       })
+                       .set_name ("Warning")
+                       .set_start (() => { push (_factory.create_paragraph ()); })
+                       .set_reduce (() => {
+                               var head = _factory.create_warning ();
+                               head.content.add ((Paragraph) pop ());
+                               ((BlockContent) peek ()).content.add (head);
+
+                               Text last_element = head.content.last () as Text;
+                               if (last_element != null) {
+                                       last_element.content._chomp ();
+                               }
+                       });
+
+               Rule note =
+                       Rule.seq ({
+                               TokenType.str ("Note:"),
+                               optional_invisible_spaces,
+                               Rule.many ({
+                                       Rule.seq({optional_invisible_spaces, run}),
+                                       TokenType.EOL.action (() => { add_content_space (); })
+                               })
+                       })
+                       .set_name ("Note")
+                       .set_start (() => { push (_factory.create_paragraph ()); })
+                       .set_reduce (() => {
+                               var head = _factory.create_note ();
+                               head.content.add ((Paragraph) pop ());
+                               ((BlockContent) peek ()).content.add (head);
+
+                               Text last_element = head.content.last () as Text;
+                               if (last_element != null) {
+                                       last_element.content._chomp ();
+                               }
+                       });
+
                Rule indented_item =
                        Rule.seq ({
                                Rule.many ({
@@ -667,6 +711,8 @@ public class Valadoc.DocumentationParser : Object, ResourceLocator {
                                indented_blocks,
                                table,
                                headline,
+                               warning,
+                               note,
                                paragraph
                        })
                        .set_name ("Blocks");
index 7599d18510afed7bce62ccd3b30a7c743552082b..13e6cd0ebd82c139e3ed15e386761c9ee70d50a2 100755 (executable)
@@ -24,8 +24,14 @@ using GLib;
 using Valadoc.Content;
 
 public class Valadoc.Html.MarkupWriter : Valadoc.MarkupWriter {
+       private unowned FileStream stream;
+
        public MarkupWriter (FileStream stream, bool xml_declaration = true) {
-               base (stream, xml_declaration);
+               // avoid broken implicit copy
+               unowned FileStream _stream = stream;
+
+               base ((str) => { _stream.printf (str); }, xml_declaration);
+               this.stream = stream;
        }
 
        public MarkupWriter add_usemap (Charts.Chart chart) {
index 7c79047d52ba1c435b002e8f12ca97092ce93426..c6148ae6db74e260ee18d500afd586cdf4112e55 100755 (executable)
@@ -341,6 +341,23 @@ public class Valadoc.Html.HtmlRenderer : ContentRenderer {
                writer.end_tag ("p");
        }
 
+       private void visit_notification_block (BlockContent element, string headline) {
+               writer.start_tag ("div", {"class", "main_notification_block"});
+               writer.start_tag ("span", {"class", "main_block_headline"}).text (headline).end_tag ("span").text (" ");
+               writer.start_tag ("span", {"class", "main_block_content"});
+               element.accept_children (this);
+               writer.end_tag ("span");
+               writer.end_tag ("div");
+       }
+
+       public override void visit_warning (Warning element) {
+               visit_notification_block (element, "Warning:");
+       }
+
+       public override void visit_note (Note element) {
+               visit_notification_block (element, "Note:");
+       }
+
        public override void visit_run (Run element) {
                string tag = null;
                string css_type = null;