current_builder.append ("\n");
}
+ public override void visit_wiki_link (WikiLink link) {
+ // wiki pages are not supported right now
+ if (link.content.size > 0) {
+ link.accept_children (this);
+ } else {
+ current_builder.append (link.name);
+ }
+ }
+
public override void visit_link (Link link) {
current_builder.append_printf ("<ulink url=\"%s\">", link.url);
link.accept_children (this);
content/inline.vala \
content/inlinetaglet.vala \
content/inlinecontent.vala \
+ content/wikilink.vala \
content/link.vala \
content/list.vala \
content/listitem.vala \
return (Link) configure (new Link ());
}
+ public WikiLink create_wiki_link () {
+ return (WikiLink) configure (new WikiLink ());
+ }
+
public List create_list () {
return (List) configure (new List ());
}
public virtual void visit_link (Link element) {
}
+ public virtual void visit_wiki_link (WikiLink element) {
+ }
+
public virtual void visit_symbol_link (SymbolLink element) {
}
--- /dev/null
+/* link.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.WikiLink : InlineContent, Inline {
+ public WikiPage page { get; private set; }
+ public string name { get; set; }
+
+ internal WikiLink () {
+ base ();
+ }
+
+ public override void configure (Settings settings, ResourceLocator locator) {
+ }
+
+ public override void check (Api.Tree api_root, Api.Node container, ErrorReporter reporter, Settings settings) {
+ page = api_root.wikitree.search (name);
+ if (page == null) {
+ reporter.simple_warning ("%s does not exist".printf (name));
+ return ;
+ }
+ }
+
+ public override void accept (ContentVisitor visitor) {
+ visitor.visit_wiki_link (this);
+ }
+}
Rule link =
Rule.seq ({
TokenType.DOUBLE_OPEN_BRACKET.action (() => { ((WikiScanner) _scanner).set_url_escape_mode (true); }),
- TokenType.any_word ().action ((token) => { ((Link) peek ()).url = token.to_string (); }),
+ TokenType.any_word ().action ((token) => {
+ var url = token.to_string ();
+ if (url.has_suffix (".valadoc")) {
+ var link = _factory.create_wiki_link ();
+ link.name = url;
+ push (link);
+ } else {
+ var link = _factory.create_link ();
+ link.url = url;
+ push (link);
+ }
+ }),
Rule.option ({
TokenType.PIPE.action (() => { ((WikiScanner) _scanner).set_url_escape_mode (false); }),
run
}),
TokenType.DOUBLE_CLOSED_BRACKET.action (() => { ((WikiScanner) _scanner).set_url_escape_mode (false); })
})
- .set_name ("Link")
- .set_start (() => { push (_factory.create_link ()); });
-
+ .set_name ("Link");
Rule source_code =
Rule.seq ({
TokenType.TRIPLE_OPEN_BRACE.action ((token) => { ((WikiScanner) _scanner).set_code_escape_mode (true); }),
element.accept_children (this);
}
- private string get_url (Api.Node symbol) {
+ private string get_url (Documentation symbol) {
return linker.get_relative_link (_container, symbol, settings);
}
writer.end_tag ("h%d".printf (element.level));
}
+ public override void visit_wiki_link (WikiLink element) {
+ if (element.page != null) {
+ writer.start_tag ("a", {"href", get_url (element.page)});
+ }
+
+ if (element.content.size > 0) {
+ element.accept_children (this);
+ } else {
+ writer.text (element.name.substring (0, element.name.last_index_of_char ('.')));
+ }
+
+ if (element.page != null) {
+ writer.end_tag ("a");
+ }
+ }
+
public override void visit_link (Link element) {
writer.start_tag ("a", {"href", element.url});
if (element.content.size > 0) {