[valadoc] Add warning & note tags
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] Add warning & note tags
- Date: Fri, 27 Jan 2012 16:44:17 +0000 (UTC)
commit b753b88a432fca3a8947a1ea0743e44f626e23a2
Author: Florian Brosch <flo brosch gmail com>
Date: Thu Jan 5 03:24:02 2012 +0100
Add warning & note tags
icons/Makefile.am | 1 +
icons/tip.png | Bin 0 -> 766 bytes
src/doclets/gtkdoc/commentconverter.vala | 14 ++++++-
src/libvaladoc/Makefile.am | 4 ++
src/libvaladoc/content/contentfactory.vala | 7 +++
src/libvaladoc/content/contentvisitor.vala | 6 +++
src/libvaladoc/content/note.vala | 40 +++++++++++++++++
src/libvaladoc/content/warning.vala | 40 +++++++++++++++++
.../documentation/documentationparser.vala | 46 ++++++++++++++++++++
src/libvaladoc/html/htmlmarkupwriter.vala | 8 +++-
src/libvaladoc/html/htmlrenderer.vala | 17 +++++++
11 files changed, 181 insertions(+), 2 deletions(-)
---
diff --git a/icons/Makefile.am b/icons/Makefile.am
index 5869bff..4859e24 100644
--- a/icons/Makefile.am
+++ b/icons/Makefile.am
@@ -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
index 0000000..6ccf512
Binary files /dev/null and b/icons/tip.png differ
diff --git a/src/doclets/gtkdoc/commentconverter.vala b/src/doclets/gtkdoc/commentconverter.vala
index a0c3372..e10b8aa 100755
--- a/src/doclets/gtkdoc/commentconverter.vala
+++ b/src/doclets/gtkdoc/commentconverter.vala
@@ -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);
}
diff --git a/src/libvaladoc/Makefile.am b/src/libvaladoc/Makefile.am
index 310a3db..fe3115c 100755
--- a/src/libvaladoc/Makefile.am
+++ b/src/libvaladoc/Makefile.am
@@ -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 \
diff --git a/src/libvaladoc/content/contentfactory.vala b/src/libvaladoc/content/contentfactory.vala
index 55c44f7..19cf41b 100755
--- a/src/libvaladoc/content/contentfactory.vala
+++ b/src/libvaladoc/content/contentfactory.vala
@@ -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));
}
diff --git a/src/libvaladoc/content/contentvisitor.vala b/src/libvaladoc/content/contentvisitor.vala
index bacffc3..3eb3a4b 100755
--- a/src/libvaladoc/content/contentvisitor.vala
+++ b/src/libvaladoc/content/contentvisitor.vala
@@ -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
index 0000000..d2b16c5
--- /dev/null
+++ b/src/libvaladoc/content/note.vala
@@ -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
index 0000000..e848c43
--- /dev/null
+++ b/src/libvaladoc/content/warning.vala
@@ -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);
+ }
+}
+
diff --git a/src/libvaladoc/documentation/documentationparser.vala b/src/libvaladoc/documentation/documentationparser.vala
index b2a96f0..1b29698 100755
--- a/src/libvaladoc/documentation/documentationparser.vala
+++ b/src/libvaladoc/documentation/documentationparser.vala
@@ -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");
diff --git a/src/libvaladoc/html/htmlmarkupwriter.vala b/src/libvaladoc/html/htmlmarkupwriter.vala
index 7599d18..13e6cd0 100755
--- a/src/libvaladoc/html/htmlmarkupwriter.vala
+++ b/src/libvaladoc/html/htmlmarkupwriter.vala
@@ -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) {
diff --git a/src/libvaladoc/html/htmlrenderer.vala b/src/libvaladoc/html/htmlrenderer.vala
index 7c79047..c6148ae 100755
--- a/src/libvaladoc/html/htmlrenderer.vala
+++ b/src/libvaladoc/html/htmlrenderer.vala
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]