[valadoc] Add colored output



commit 178d5058806b2a5647bf113b714be9b6134c1a6b
Author: Florian Brosch <flo brosch gmail com>
Date:   Wed May 13 18:12:29 2015 +0200

    Add colored output
    
    Use --no-color to disable colors
    Use VALA_COLORS to change colors
    
    E.g. VALA_COLORS = "error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01"

 src/doclets/gtkdoc/commentconverter.vala           |    8 +-
 src/doclets/gtkdoc/dbus.vala                       |    4 +-
 src/doclets/gtkdoc/doclet.vala                     |   29 +-
 src/doclets/gtkdoc/gcomment.vala                   |    2 +-
 src/doclets/gtkdoc/generator.vala                  |   10 +-
 src/doclets/gtkdoc/utils.vala                      |    5 +-
 src/libvaladoc/api/tree.vala                       |    2 +-
 src/libvaladoc/content/embedded.vala               |   16 +-
 src/libvaladoc/content/link.vala                   |    3 +-
 src/libvaladoc/content/sourcecode.vala             |   15 +-
 src/libvaladoc/content/wikilink.vala               |    3 +-
 src/libvaladoc/documentation/girmetadata.vala      |   10 +-
 src/libvaladoc/documentation/wiki.vala             |    4 +-
 src/libvaladoc/errorreporter.vala                  |  280 +++++++++++++++++++-
 .../importer/valadocdocumentationimporter.vala     |    4 +-
 src/libvaladoc/markupreader.vala                   |    8 +-
 src/libvaladoc/moduleloader.vala                   |    6 +-
 src/libvaladoc/settings.vala                       |    5 +
 src/libvaladoc/taglets/tagletdeprecated.vala       |    4 +-
 src/libvaladoc/taglets/tagletinheritdoc.vala       |    4 +-
 src/libvaladoc/taglets/tagletlink.vala             |    4 +-
 src/libvaladoc/taglets/tagletparam.vala            |   12 +-
 src/libvaladoc/taglets/tagletreturn.vala           |    8 +-
 src/libvaladoc/taglets/tagletsee.vala              |    4 +-
 src/libvaladoc/taglets/tagletthrows.vala           |   12 +-
 src/valadoc/valadoc.vala                           |   51 +++-
 26 files changed, 410 insertions(+), 103 deletions(-)
---
diff --git a/src/doclets/gtkdoc/commentconverter.vala b/src/doclets/gtkdoc/commentconverter.vala
index cdf85ea..6950a1a 100644
--- a/src/doclets/gtkdoc/commentconverter.vala
+++ b/src/doclets/gtkdoc/commentconverter.vala
@@ -78,7 +78,7 @@ public class Gtkdoc.CommentConverter : ContentVisitor {
 
        public override void visit_headline (Headline hl) {
                // what to do here?
-               reporter.simple_warning ("GtkDoc: warning: Headline elements not supported");
+               reporter.simple_warning ("GtkDoc", "Headline elements not supported");
                current_builder.append ("\n");
                hl.accept_children (this);
                current_builder.append ("\n");
@@ -151,8 +151,8 @@ public class Gtkdoc.CommentConverter : ContentVisitor {
                        break;
 
                default:
-                       reporter.simple_warning ("GtkDoc: warning: unsupported list type: %s",
-                                                                        list.bullet.to_string ());
+                       reporter.simple_warning ("GtkDoc",
+                                                                        "unsupported list type: '%s'", 
list.bullet.to_string ());
                        break;
                }
 
@@ -292,7 +292,7 @@ public class Gtkdoc.CommentConverter : ContentVisitor {
                                                                           link,
                                                                           current_builder.str);
                } else {
-                       reporter.simple_warning ("GtkDoc: warning: Taglet not supported"); // TODO
+                       reporter.simple_warning ("GtkDoc", "Taglet not supported"); // TODO
                }
                current_builder = (owned)old_builder;
        }
diff --git a/src/doclets/gtkdoc/dbus.vala b/src/doclets/gtkdoc/dbus.vala
index d147407..be6cb5f 100644
--- a/src/doclets/gtkdoc/dbus.vala
+++ b/src/doclets/gtkdoc/dbus.vala
@@ -155,8 +155,8 @@ namespace Gtkdoc.DBus {
                                                                                                
"%s.xml".printf (to_docbook_id (name)));
                        var writer = new TextWriter (xml_file, "w");
                        if (!writer.open ()) {
-                               reporter.simple_error ("GtkDoc: error: unable to open %s for writing",
-                                                                          writer.filename);
+                               reporter.simple_error ("GtkDoc",
+                                                                          "unable to open '%s' for writing", 
writer.filename);
                                return false;
                        }
                        writer.write_line (to_string (reporter));
diff --git a/src/doclets/gtkdoc/doclet.vala b/src/doclets/gtkdoc/doclet.vala
index 74e16c1..ae6066c 100644
--- a/src/doclets/gtkdoc/doclet.vala
+++ b/src/doclets/gtkdoc/doclet.vala
@@ -58,7 +58,7 @@ namespace Gtkdoc.Config {
                        unowned string[] gtkdoc_args = args;
                        opt_context.parse (ref gtkdoc_args);
                } catch (OptionError e) {
-                       reporter.simple_error ("GtkDoc: error: %s\nRun '-X --help' to see a full list of 
available command line options.", e.message);
+                       reporter.simple_error ("GtkDoc", "%s\nRun '-X --help' to see a full list of available 
command line options.", e.message);
                        return false;
                }
 
@@ -156,7 +156,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                }
 
                if (!copy_file (filename, Path.build_filename (comments_dir, Path.get_basename (filename)))) {
-                       reporter.simple_error ("GtkDoc: error: Can't copy %s", filename);
+                       reporter.simple_error ("GtkDoc", "Can't copy '%s'", filename);
                }
        }
 
@@ -187,7 +187,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                        prepared += filename;
 
                        if (!FileUtils.test (filename, FileTest.EXISTS)) {
-                               reporter.simple_error ("GtkDoc: error: %s not found", relative_filename);
+                               reporter.simple_error ("GtkDoc", "'%s' not found", relative_filename);
                                continue;
                        }
 
@@ -196,13 +196,14 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                        } else if (filename.has_suffix (".h")) {
                                prepare_h_file (filename);
                        } else {
-                               reporter.simple_error ("GtkDoc: error: %s is not a supported source file 
type. Only .h, and .c files are supported.",
+                               reporter.simple_error ("GtkDoc",
+                                                                          "'%s' is not a supported source 
file type. Only .h, and .c files are supported.",
                                                                           relative_filename);
                        }
                }
 
                if (vala_headers.length <= 0) {
-                       reporter.simple_error ("GtkDoc: error: No vala header found");
+                       reporter.simple_error ("GtkDoc", "No vala header found");
                }
 
                return reporter.errors == 0;
@@ -237,7 +238,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                try {
                        Process.spawn_sync (settings.path, args, null, SpawnFlags.SEARCH_PATH, null, null, 
null);
                } catch (Error e) {
-                       reporter.simple_error ("gtkdoc-scan: error: %s", e.message);
+                       reporter.simple_error ("gtkdoc-scan", "%s", e.message);
                        return false;
                }
 
@@ -288,7 +289,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                        string cflags;
                        Process.spawn_sync (null, pc_cflags, null, SpawnFlags.SEARCH_PATH, null, out cflags, 
out stderr, out status);
                        if (status != 0) {
-                               reporter.simple_error ("GtkDoc: error: pkg-config cflags error: %s", stderr);
+                               reporter.simple_error ("GtkDoc", "pkg-config cflags error: %s", stderr);
                                return false;
                        }
                        cflags = cflags.strip ();
@@ -296,7 +297,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                        string libs;
                        Process.spawn_sync (null, pc_libs, null, SpawnFlags.SEARCH_PATH, null, out libs, out 
stderr, out status);
                        if (status != 0) {
-                               reporter.simple_error ("GtkDoc: error: pkg-config libs error: %s", stderr);
+                               reporter.simple_error ("GtkDoc", "pkg-config libs error: %s", stderr);
                                return false;
                        }
 
@@ -321,7 +322,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
 
                        Process.spawn_sync (settings.path, args, env, SpawnFlags.SEARCH_PATH, null, null, 
null);
                } catch (Error e) {
-                       reporter.simple_error ("gtkdoc-scangobj: error: %s", e.message);
+                       reporter.simple_error ("gtkdoc-scangobj", "%s", e.message);
                        return false;
                }
 
@@ -344,7 +345,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                try {
                        Process.spawn_sync (settings.path, args, null, SpawnFlags.SEARCH_PATH, null, null, 
null);
                } catch (Error e) {
-                       reporter.simple_error ("gtkdoc-mkdb: error: %s", e.message);
+                       reporter.simple_error ("gtkdoc-mkdb", "%s", e.message);
                        return false;
                }
 
@@ -354,7 +355,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                        try {
                                FileUtils.get_contents (main_file, out contents);
                        } catch (Error e) {
-                               reporter.simple_error ("GtkDoc: error: Error while reading main file '%s' 
contents: %s",
+                               reporter.simple_error ("GtkDoc", "Error while reading main file '%s' 
contents: %s",
                                                                           main_file, e.message);
                                return false;
                        }
@@ -390,7 +391,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                        try {
                                FileUtils.set_contents (main_file, contents);
                        } catch (Error e) {
-                               reporter.simple_error ("GtkDoc: error: Error while writing main file '%s' 
contents: %s",
+                               reporter.simple_error ("GtkDoc", "Error while writing main file '%s' 
contents: %s",
                                                                           main_file, e.message);
                                return false;
                        }
@@ -413,7 +414,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                                                  settings.pkg_name, "../%s-docs.xml".printf 
(settings.pkg_name)},
                                                null, SpawnFlags.SEARCH_PATH, null, null, null);
                } catch (Error e) {
-                       reporter.simple_error ("gtkdoc-mkhtml: error: %s", e.message);
+                       reporter.simple_error ("gtkdoc-mkhtml", "%s", e.message);
                        return false;
                }
 
@@ -426,7 +427,7 @@ public class Gtkdoc.Director : Valadoc.Doclet, Object {
                                                  "--html-dir", html_dir },
                                                null, SpawnFlags.SEARCH_PATH, null, null, null);
                } catch (Error e) {
-                       reporter.simple_error ("gtkdoc-fixxref: error: %s", e.message);
+                       reporter.simple_error ("gtkdoc-fixxref", "%s", e.message);
                        return false;
                }
 
diff --git a/src/doclets/gtkdoc/gcomment.vala b/src/doclets/gtkdoc/gcomment.vala
index a23b545..623e3c4 100644
--- a/src/doclets/gtkdoc/gcomment.vala
+++ b/src/doclets/gtkdoc/gcomment.vala
@@ -151,7 +151,7 @@ public class Gtkdoc.GComment {
                        } else if (header.name == "Since") {
                                since = header.value;
                        } else {
-                               reporter.simple_warning ("GtkDoc: warning: Unknown versioning tag '%s'", 
header.name);
+                               reporter.simple_warning ("GtkDoc", "Unknown versioning tag '%s'", 
header.name);
                        }
                }
 
diff --git a/src/doclets/gtkdoc/generator.vala b/src/doclets/gtkdoc/generator.vala
index 1d6f821..98c1d25 100644
--- a/src/doclets/gtkdoc/generator.vala
+++ b/src/doclets/gtkdoc/generator.vala
@@ -108,7 +108,7 @@ public class Gtkdoc.Generator : Api.Visitor {
 
                var sections_writer = new TextWriter (sections, "a");
                if (!sections_writer.open ()) {
-                       reporter.simple_error ("GtkDoc: error: unable to open %s for writing", 
sections_writer.filename);
+                       reporter.simple_error ("GtkDoc", "unable to open '%s' for writing", 
sections_writer.filename);
                        return false;
                }
 
@@ -118,7 +118,7 @@ public class Gtkdoc.Generator : Api.Visitor {
                        var cwriter = new TextWriter (Path.build_filename (code_dir, "%s.c".printf 
(basename)), "w");
 
                        if (!cwriter.open ()) {
-                               reporter.simple_error ("GtkDoc: error: unable to open %s for writing", 
cwriter.filename);
+                               reporter.simple_error ("GtkDoc", "unable to open '%s' for writing", 
cwriter.filename);
                                return false;
                        }
 
@@ -259,7 +259,7 @@ public class Gtkdoc.Generator : Api.Visitor {
                 * forward that as a Valadoc warning so that it doesn’t get lost
                 * in the gtk-doc output files. */
                if (gcomment.long_comment == null || gcomment.long_comment == "") {
-                       reporter.simple_warning ("Missing long description in the documentation for ‘%s’ 
which forms gtk-doc section ‘%s’.",
+                       reporter.simple_warning ("GtkDoc", "Missing long description in the documentation for 
‘%s’ which forms gtk-doc section ‘%s’.",
                                                                         symbol_full_name,
                                                                         section_name);
                }
@@ -1378,7 +1378,7 @@ It is important that your <link linkend=\"GValue\"><type>GValue</type></link> ho
                        }
 
                        if (replacement != null && replacement_symbol == null) {
-                               reporter.simple_warning ("Couldn’t resolve replacement symbol ‘%s’ for 
‘Deprecated’ attribute on %s.",
+                               reporter.simple_warning ("GtkDoc", "Couldn’t resolve replacement symbol ‘%s’ 
for ‘Deprecated’ attribute on %s.",
                                                                                 replacement_symbol_name,
                                                                                 sym.get_full_name ());
                        }
@@ -1392,7 +1392,7 @@ It is important that your <link linkend=\"GValue\"><type>GValue</type></link> ho
                        } else if (since == null && replacement_symbol != null) {
                                deprecation_string = "Replaced by %s.".printf (get_gtkdoc_link 
(replacement_symbol));
                        } else {
-                               reporter.simple_warning ("Missing ‘since’ and ‘replacement’ arguments to 
‘Deprecated’ attribute on %s.",
+                               reporter.simple_warning ("GtkDoc", "Missing ‘since’ and ‘replacement’ 
arguments to ‘Deprecated’ attribute on %s.",
                                                                                 sym.get_full_name ());
                        }
 
diff --git a/src/doclets/gtkdoc/utils.vala b/src/doclets/gtkdoc/utils.vala
index 53bf8fb..be55172 100644
--- a/src/doclets/gtkdoc/utils.vala
+++ b/src/doclets/gtkdoc/utils.vala
@@ -219,9 +219,8 @@ namespace Gtkdoc {
                        Process.spawn_command_line_sync (pc, null, null, out exit_status);
                        return (0 == exit_status);
                } catch (SpawnError e) {
-                       reporter.simple_warning ("GtkDoc: warning: Error pkg-config --exists %s: %s",
-                                                                        package_name,
-                                                                        e.message);
+                       reporter.simple_warning ("GtkDoc",
+                                                                        "Error pkg-config --exists %s: %s", 
package_name, e.message);
                        return false;
                }
        }
diff --git a/src/libvaladoc/api/tree.vala b/src/libvaladoc/api/tree.vala
index 9221fe6..8464926 100644
--- a/src/libvaladoc/api/tree.vala
+++ b/src/libvaladoc/api/tree.vala
@@ -333,7 +333,7 @@ public class Valadoc.Api.Tree {
                        }
 
                        if (imported == false) {
-                               reporter.simple_error ("error: %s not found in specified import directories", 
pkg_name);
+                               reporter.simple_error (null, "'%s' not found in specified import 
directories", pkg_name);
                        }
                }
        }
diff --git a/src/libvaladoc/content/embedded.vala b/src/libvaladoc/content/embedded.vala
index 47add58..7178aa2 100644
--- a/src/libvaladoc/content/embedded.vala
+++ b/src/libvaladoc/content/embedded.vala
@@ -79,8 +79,22 @@ public class Valadoc.Content.Embedded : ContentElement, Inline, StyleAttributes
 
                // search relative to the current directory / absoulte path
                if (!FileUtils.test (url, FileTest.EXISTS | FileTest.IS_REGULAR)) {
+                       string base_name = Path.get_basename (url);
+
+                       foreach (unowned string dir in settings.alternative_ressource_dirs) {
+                               string alternative_path = Path.build_path (Path.DIR_SEPARATOR_S,
+                                                                                                             
   dir,
+                                                                                                             
   base_name);
+                               if (FileUtils.test (alternative_path, FileTest.EXISTS | FileTest.IS_REGULAR)) 
{
+                                       url = (owned) alternative_path;
+                                       package = container.package;
+                                       return ;
+                               }
+                       }
+
                        string node_segment = (container is Api.Package)? "" : container.get_full_name () + 
": ";
-                       reporter.simple_error ("%s: %s{{: error: %s does not exist", file_path, node_segment, 
url);
+                       reporter.simple_error ("%s: %s{{".printf (file_path, node_segment),
+                                                                  "'%s' does not exist", url);
                } else {
                        package = container.package;
                }
diff --git a/src/libvaladoc/content/link.vala b/src/libvaladoc/content/link.vala
index 2dad00a..ba641e7 100644
--- a/src/libvaladoc/content/link.vala
+++ b/src/libvaladoc/content/link.vala
@@ -69,7 +69,8 @@ public class Valadoc.Content.Link : InlineContent, Inline {
                        string _url = id_registrar.map_url_id (url);
                        if (_url == null) {
                                string node_segment = (container is Api.Package)? "" : 
container.get_full_name () + ": ";
-                               reporter.simple_warning ("%s: %s[[: warning: unknown imported internal id 
`%s'", file_path, node_segment, url);
+                               reporter.simple_warning ("%s: %s[[".printf (file_path, node_segment),
+                                                                                "unknown imported internal 
id '%s'", url);
 
                                InlineContent _parent = parent as InlineContent;
                                assert (_parent != null);
diff --git a/src/libvaladoc/content/sourcecode.vala b/src/libvaladoc/content/sourcecode.vala
index dd84f1f..8e9fca3 100644
--- a/src/libvaladoc/content/sourcecode.vala
+++ b/src/libvaladoc/content/sourcecode.vala
@@ -109,8 +109,9 @@ public class Valadoc.Content.SourceCode : ContentElement, Inline {
                // search relative to the current directory / absoulte path
                if (!FileUtils.test (path, FileTest.EXISTS | FileTest.IS_REGULAR)) {
                        string node_segment = (container is Api.Package)? "" : container.get_full_name () + 
": ";
-                       code = "File %s does not exist".printf (path);
-                       reporter.simple_warning ("%s: %s{{{: warning: %s", source_file_path, node_segment, 
code);
+                       code = "File '%s' does not exist".printf (path);
+                       reporter.simple_warning ("%s: %s{{{".printf (source_file_path, node_segment),
+                                                                        "%s", code);
                        return null;
                }
 
@@ -132,10 +133,8 @@ public class Valadoc.Content.SourceCode : ContentElement, Inline {
                        code = (owned) content;
                } catch (FileError err) {
                        string node_segment = (container is Api.Package)? "" : container.get_full_name () + 
": ";
-                       reporter.simple_error ("%s: %s{{{: error: Can't read file %s: %s", source_file_path,
-                                                                  node_segment,
-                                                                  path,
-                                                                  err.message);
+                       reporter.simple_error ("%s: %s{{{".printf (source_file_path, node_segment),
+                                                                  "Can't read file '%s': %s", path, 
err.message);
                }
        }
 
@@ -180,8 +179,8 @@ public class Valadoc.Content.SourceCode : ContentElement, Inline {
                                code = splitted[1] ?? "";
                                if (_language == null && name != "none") {
                                        string node_segment = (container is Api.Package)? "" : 
container.get_full_name () + ": ";
-                                       reporter.simple_warning ("%s: %s{{{: warning: Unsupported programming 
language '%s'",
-                                                                                        file_path, 
node_segment, name);
+                                       reporter.simple_warning ("%s: %s{{{".printf (file_path, node_segment),
+                                                                                        "Unsupported 
programming language '%s'", name);
                                }
                        }
                }
diff --git a/src/libvaladoc/content/wikilink.vala b/src/libvaladoc/content/wikilink.vala
index 7394a96..1c18031 100644
--- a/src/libvaladoc/content/wikilink.vala
+++ b/src/libvaladoc/content/wikilink.vala
@@ -47,7 +47,8 @@ public class Valadoc.Content.WikiLink : InlineContent, Inline {
                page = api_root.wikitree.search (name);
                if (page == null) {
                        string node_segment = (container is Api.Package)? "" : container.get_full_name () + 
": ";
-                       reporter.simple_warning ("%s: %s[[: warning: %s does not exist".printf (file_path, 
node_segment, name));
+                       reporter.simple_warning ("%s: %s[[".printf (file_path, node_segment),
+                                                                        "'%s' does not exist", name);
                        return ;
                }
        }
diff --git a/src/libvaladoc/documentation/girmetadata.vala b/src/libvaladoc/documentation/girmetadata.vala
index c6ea643..2dbae65 100644
--- a/src/libvaladoc/documentation/girmetadata.vala
+++ b/src/libvaladoc/documentation/girmetadata.vala
@@ -104,7 +104,7 @@ public class Valadoc.GirMetaData : Object {
                                break;
 
                        default:
-                               reporter.simple_warning ("%s: warning: Unknown key 'General.%s'", 
metadata_path, key);
+                               reporter.simple_warning (metadata_path, "Unknown key 'General.%s'", key);
                                break;
                        }
                }
@@ -126,10 +126,10 @@ public class Valadoc.GirMetaData : Object {
                        key_file = new KeyFile ();
                        key_file.load_from_file (metadata_path, KeyFileFlags.NONE);
                } catch (KeyFileError e) {
-                       reporter.simple_error ("%s: error: %s\n", metadata_path, e.message);
+                       reporter.simple_error (metadata_path, "%s", e.message);
                        return ;
                } catch (FileError e) {
-                       reporter.simple_error ("%s: error: %s\n", metadata_path, e.message);
+                       reporter.simple_error (metadata_path, "%s", e.message);
                        return ;
                }
 
@@ -141,12 +141,12 @@ public class Valadoc.GirMetaData : Object {
                                        break;
 
                                default:
-                                       reporter.simple_warning ("%s: warning: Unknown group '%s'\n", 
metadata_path, group);
+                                       reporter.simple_warning (metadata_path, "Unknown group '%s'", group);
                                        break;
                                }
                        }
                } catch (KeyFileError e) {
-                       reporter.simple_error ("%s: error: %s", metadata_path, e.message);
+                       reporter.simple_error (null, "Unable to read file '%s': %s", metadata_path, 
e.message);
                }
 
 
diff --git a/src/libvaladoc/documentation/wiki.vala b/src/libvaladoc/documentation/wiki.vala
index fac10e5..0f8f492 100644
--- a/src/libvaladoc/documentation/wiki.vala
+++ b/src/libvaladoc/documentation/wiki.vala
@@ -72,7 +72,7 @@ public class Valadoc.WikiPage : Object, Documentation {
                        FileUtils.get_contents (this.path, out content);
                        this.documentation_str = content;
                } catch (FileError err) {
-                       reporter.simple_error ("error: Unable to read file `%s': %s", this.path, err.message);
+                       reporter.simple_error (null, "Unable to read file '%s': %s", this.path, err.message);
                }
        }
 
@@ -127,7 +127,7 @@ public class Valadoc.WikiPageTree : Object {
                                }
                        }
                } catch (FileError err) {
-                       reporter.simple_error ("error: Unable to open directory `%s': %s", path, err.message);
+                       reporter.simple_error (null, "Unable to open directory '%s': %s", path, err.message);
                }
        }
 
diff --git a/src/libvaladoc/errorreporter.vala b/src/libvaladoc/errorreporter.vala
index 6c5a794..49d2b3d 100644
--- a/src/libvaladoc/errorreporter.vala
+++ b/src/libvaladoc/errorreporter.vala
@@ -27,6 +27,72 @@ public class Valadoc.ErrorReporter : Object {
        private int _warnings = 0;
        private int _errors = 0;
 
+       /**
+        * SGR end tag
+        */
+       private const string ANSI_COLOR_END = "\x1b[0m";
+
+       /**
+        * SGR start tag for source location
+        */
+       private string locus_color_start = "";
+
+       /**
+        * SGR end tag for source location
+        */
+       private unowned string locus_color_end = "";
+
+       /**
+        * SGR start tag for warning titles
+        */
+       private string warning_color_start = "";
+
+       /**
+        * SGR end tag for warning titles
+        */
+       private unowned string warning_color_end = "";
+
+       /**
+        * SGR start tag for error titles
+        */
+       private string error_color_start = "";
+
+       /**
+        * SGR end tag for error titles
+        */
+       private unowned string error_color_end = "";
+
+       /**
+        * SGR start tag for note titles
+        */
+       private string note_color_start = "";
+
+       /**
+        * SGR end tag for note titles
+        */
+       private unowned string note_color_end = "";
+
+       /**
+        * SGR start tag for caret line (^^^)
+        */
+       private string caret_color_start = "";
+
+       /**
+        * SGR end tag for caret line (^^^)
+        */
+       private unowned string caret_color_end = "";
+
+       /**
+        * SGR start tag for quotes line ('', ``, `')
+        */
+       private string quote_color_start = "";
+
+       /**
+        * SGR end tag for quotes line ('', ``, `')
+        */
+       private unowned string quote_color_end = "";
+
+
        public int warnings_offset {
                get;
                set;
@@ -65,16 +131,137 @@ public class Valadoc.ErrorReporter : Object {
                this.settings = settings;
        }
 
-       private inline void msg (string type, string file, long line, long startpos, long endpos,
+       /**
+        * Set all colors by string
+        *
+        * {{{
+        *   "error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01"
+        * }}}
+        */
+       public bool set_colors (string str) {
+               Regex val_regex;
+               try {
+                       val_regex = new Regex ("^\\s*[0-9]+(;[0-9]*)*\\s*$");
+               } catch (RegexError e) {
+                       assert_not_reached ();
+               }
+
+               string error_color = null;
+               string warning_color = null;
+               string note_color = null;
+               string caret_color = null;
+               string locus_color = null;
+               string quote_color = null;
+
+               string[] fragments = str.split (":");
+               foreach (unowned string fragment in fragments) {
+                       string[] eq = fragment.split ("=", 2);
+                       if (eq.length != 2) {
+                               return false;
+                       }
+
+                       if (!val_regex.match (eq[1])) {
+                               return false;
+                       }
+
+
+                       unowned string checked_value = eq[1]._strip ();
+                       switch (eq[0]._strip ()) {
+                       case "error":
+                               error_color = checked_value;
+                               break;
+
+                       case "warning":
+                               warning_color = checked_value;
+                               break;
+
+                       case "note":
+                               note_color = checked_value;
+                               break;
+
+                       case "caret":
+                               caret_color = checked_value;
+                               break;
+
+                       case "locus":
+                               locus_color = checked_value;
+                               break;
+
+                       case "quote":
+                               quote_color = checked_value;
+                               break;
+
+                       default:
+                               return false;
+                       }
+               }
+
+               if (is_atty (this.stream.fileno ())) {
+                       if (error_color != null) {
+                               this.error_color_start = "\x1b[0" + error_color + "m";
+                               this.error_color_end = ANSI_COLOR_END;
+                       }
+
+                       if (warning_color != null) {
+                               this.warning_color_start = "\x1b[0" + warning_color + "m";
+                               this.warning_color_end = ANSI_COLOR_END;
+                       }
+
+                       if (note_color != null) {
+                               this.note_color_start = "\x1b[0" + note_color + "m";
+                               this.note_color_end = ANSI_COLOR_END;
+                       }
+
+                       if (caret_color != null) {
+                               this.caret_color_start = "\x1b[0" + caret_color + "m";
+                               this.caret_color_end = ANSI_COLOR_END;
+                       }
+
+                       if (locus_color != null) {
+                               this.locus_color_start = "\x1b[0" + locus_color + "m";
+                               this.locus_color_end = ANSI_COLOR_END;
+                       }
+
+                       if (quote_color != null) {
+                               this.quote_color_start = "\x1b[0" + quote_color + "m";
+                               this.quote_color_end = ANSI_COLOR_END;
+                       }
+               }
+               return true;
+       }
+
+       [CCode (has_target = false)]
+       private delegate int AttyFunc (int fd);
+
+       private bool is_atty (int fd) {
+               Module module = Module.open (null, ModuleFlags.BIND_LAZY);
+               if (module == null) {
+                       return false;
+               }
+
+               void* _func;
+               module.symbol ("isatty", out _func);
+               if (_func == null) {
+                       return false;
+               }
+
+               AttyFunc? func = (AttyFunc) _func;
+               return func (fd) == 1;
+       }
+
+       private inline void msg (string type, string type_color_start, string type_color_end, string file, 
long line, long startpos, long endpos,
                                                         string errline, string msg_format, va_list args)
        {
-               this.stream.printf ("%s:%lu.%lu-%lu.%lu: %s: ", file, line, startpos,
-                                                       line, endpos, type);
-               this.stream.vprintf (msg_format, args);
+               this.stream.printf ("%s%s:%lu.%lu-%lu.%lu:%s %s%s:%s ",
+                                                       locus_color_start, file, line, startpos, line, 
endpos, locus_color_end,
+                                                       type_color_start, type, type_color_end);
+               print_highlighted_message (msg_format.vprintf (args));
                this.stream.putc ('\n');
 
                if (startpos <= endpos) {
                        this.stream.printf ("%s\n", errline);
+
+                       this.stream.puts (caret_color_start);
                        for (int i = 0; i < errline.char_count ()+1; i++) {
                                if (errline[i] == '\t') {
                                        this.stream.printf ("\t");
@@ -84,28 +271,97 @@ public class Valadoc.ErrorReporter : Object {
                                        this.stream.printf (" ");
                                }
                        }
+                       this.stream.puts (caret_color_end);
                        this.stream.printf ("\n");
                }
        }
 
-       public void simple_warning (string msg_format, ...) {
+       private void print_highlighted_message (string message) {
+               int start = 0;
+               int cur = 0;
+
+               while (message[cur] != '\0') {
+                       if (message[cur] == '\'' || message[cur] == '`') {
+                               unowned string end_chars = (message[cur] == '`')? "`'" : "'";
+                               this.stream.puts (message.substring (start, cur - start));
+                               start = cur;
+                               cur++;
+
+                               while (message[cur] != '\0' && end_chars.index_of_char (message[cur]) < 0) {
+                                       cur++;
+                               }
+                               if (message[cur] == '\0') {
+                                       this.stream.puts (message.substring (start, cur - start));
+                                       start = cur;
+                               } else {
+                                       cur++;
+                                       this.stream.printf ("%s%s%s", quote_color_start, message.substring 
(start, cur - start), quote_color_end);
+                                       start = cur;
+                               }
+                       } else {
+                               cur++;
+                       }
+               }
+
+               this.stream.puts (message.offset (start));
+       }
+
+       public void simple_warning (string? location, string msg_format, ...) {
                var args = va_list();
-               this.stream.vprintf (msg_format, args);
+
+               if (location != null) {
+                       this.stream.puts (locus_color_start);
+                       this.stream.puts (location);
+                       this.stream.puts (": ");
+                       this.stream.puts (locus_color_end);
+               }
+
+               this.stream.puts (warning_color_start);
+               this.stream.puts ("warning: ");
+               this.stream.puts (warning_color_end);
+
+               print_highlighted_message (msg_format.vprintf (args));
                this.stream.putc ('\n');
                this._warnings++;
        }
 
-       public void simple_error (string msg_format, ...) {
+       public void simple_error (string? location, string msg_format, ...) {
                var args = va_list();
-               this.stream.vprintf (msg_format, args);
+
+               if (location != null) {
+                       this.stream.puts (locus_color_start);
+                       this.stream.puts (location);
+                       this.stream.puts (": ");
+                       this.stream.puts (locus_color_end);
+                       this.stream.putc (' ');
+               }
+
+               this.stream.puts (error_color_start);
+               this.stream.puts ("error: ");
+               this.stream.puts (error_color_end);
+
+               print_highlighted_message (msg_format.vprintf (args));
                this.stream.putc ('\n');
                this._errors++;
        }
 
-       public void simple_note (string msg_format, ...) {
+       public void simple_note (string? location, string msg_format, ...) {
                if (_settings == null || _settings.verbose) {
                        var args = va_list();
-                       this.stream.vprintf (msg_format, args);
+
+                       if (location != null) {
+                               this.stream.puts (locus_color_start);
+                               this.stream.puts (location);
+                               this.stream.puts (": ");
+                               this.stream.puts (locus_color_end);
+                               this.stream.putc (' ');
+                       }
+
+                       this.stream.puts (note_color_start);
+                       this.stream.puts ("note: ");
+                       this.stream.puts (note_color_end);
+
+                       print_highlighted_message (msg_format.vprintf (args));
                        this.stream.putc ('\n');
                        this._warnings++;
                }
@@ -115,7 +371,7 @@ public class Valadoc.ErrorReporter : Object {
                                           string msg_format, ...)
        {
                var args = va_list();
-               this.msg ("error", file, line, startpos, endpos, errline, msg_format, args);
+               this.msg ("error", error_color_start, error_color_end, file, line, startpos, endpos, errline, 
msg_format, args);
                this._errors++;
        }
 
@@ -123,7 +379,7 @@ public class Valadoc.ErrorReporter : Object {
                                                 string msg_format, ...)
        {
                var args = va_list();
-               this.msg ("warning", file, line, startpos, endpos, errline, msg_format, args);
+               this.msg ("warning", warning_color_start, warning_color_end, file, line, startpos, endpos, 
errline, msg_format, args);
                this._warnings++;
        }
 }
diff --git a/src/libvaladoc/importer/valadocdocumentationimporter.vala 
b/src/libvaladoc/importer/valadocdocumentationimporter.vala
index d94be23..b74b430 100644
--- a/src/libvaladoc/importer/valadocdocumentationimporter.vala
+++ b/src/libvaladoc/importer/valadocdocumentationimporter.vala
@@ -149,7 +149,7 @@ public class Valadoc.Importer.ValadocDocumentationImporter : DocumentationImport
 
                if (symbol == null) {
                        if (settings.verbose) {
-                               reporter.simple_warning ("%s: warning: Node %s does not exist", filename, 
symbol_name);
+                               reporter.simple_warning (filename, "Node `%s' does not exist", symbol_name);
                        }
 
                        return ;
@@ -191,7 +191,7 @@ public class Valadoc.Importer.ValadocDocumentationImporter : DocumentationImport
                                _parser.parse ((string) content, filename, 0, 0);
                        }
                } catch (FileError err) {
-                       reporter.simple_error ("error: Unable to map file `%s': %s", filename, err.message);
+                       reporter.simple_error (null, "Unable to map file `%s': %s", filename, err.message);
                } catch (ParserError err) {
                }
        }
diff --git a/src/libvaladoc/markupreader.vala b/src/libvaladoc/markupreader.vala
index 4791c89..9f24177 100644
--- a/src/libvaladoc/markupreader.vala
+++ b/src/libvaladoc/markupreader.vala
@@ -87,7 +87,7 @@ public class Valadoc.MarkupReader : Object {
                        line = 1;
                        column = 1;
                } catch (FileError e) {
-                       reporter.simple_error ("%s: error: Unable to map file: %s", filename, e.message);
+                       reporter.simple_error (null, "Unable to map file '%s': %s", filename, e.message);
                }
        }
 
@@ -127,7 +127,8 @@ public class Valadoc.MarkupReader : Object {
                        if (u != (unichar) (-1)) {
                                current += u.to_utf8 (null);
                        } else {
-                               reporter.simple_error ("%s:%d: error: invalid UTF-8 character", filename, 
line);
+                               reporter.simple_error ("%s:%d".printf (filename, line),
+                                                                          "invalid UTF-8 character");
                        }
                }
                if (current == begin) {
@@ -256,7 +257,8 @@ public class Valadoc.MarkupReader : Object {
                while (current < end && current[0] != end_char) {
                        unichar u = ((string) current).get_char_validated ((long) (end - current));
                        if (u == (unichar) (-1)) {
-                               reporter.simple_error ("%s:%d: error: invalid UTF-8 character", filename, 
line);
+                               reporter.simple_error ("%s:%d".printf (filename, line),
+                                                                          "invalid UTF-8 character");
                        } else if (u == '&') {
                                char* next_pos = current + u.to_utf8 (null);
                                if (((string) next_pos).has_prefix ("amp;")) {
diff --git a/src/libvaladoc/moduleloader.vala b/src/libvaladoc/moduleloader.vala
index 97cfb32..06e6fe1 100644
--- a/src/libvaladoc/moduleloader.vala
+++ b/src/libvaladoc/moduleloader.vala
@@ -132,7 +132,7 @@ public class Valadoc.ModuleLoader : Object {
                        segments.length != 3 && // e.g. 0.20.3, --version
                        segments.length != 4)   // e.g. Vala 0.18.0.60-a4cdb, --version
                {
-                       reporter.simple_error ("error: Invalid driver version format.");
+                       reporter.simple_error (null, "Invalid driver version format.");
                        return null;
                }
 
@@ -150,7 +150,7 @@ public class Valadoc.ModuleLoader : Object {
                }
 
                if (!tmp) {
-                       reporter.simple_error ("error: Invalid driver version format.");
+                       reporter.simple_error (null, "Invalid driver version format.");
                        return null;
                }
 
@@ -174,7 +174,7 @@ public class Valadoc.ModuleLoader : Object {
                }
 
 
-               reporter.simple_error ("error: No suitable driver found.");
+               reporter.simple_error (null, "No suitable driver found.");
                return null;
        }
 
diff --git a/src/libvaladoc/settings.vala b/src/libvaladoc/settings.vala
index d901dd1..fc342f9 100644
--- a/src/libvaladoc/settings.vala
+++ b/src/libvaladoc/settings.vala
@@ -142,6 +142,11 @@ public class Valadoc.Settings : Object {
        public string[] metadata_directories;
 
        /**
+        * Alternative paths for ressources
+        */
+       public string[] alternative_ressource_dirs;
+
+       /**
         * A list of all gir directories.
         */
        public string[] gir_directories;
diff --git a/src/libvaladoc/taglets/tagletdeprecated.vala b/src/libvaladoc/taglets/tagletdeprecated.vala
index c10a3c6..82c01f8 100644
--- a/src/libvaladoc/taglets/tagletdeprecated.vala
+++ b/src/libvaladoc/taglets/tagletdeprecated.vala
@@ -34,8 +34,8 @@ public class Valadoc.Taglets.Deprecated : BlockContent, Taglet, Block {
                                                                ErrorReporter reporter, Settings settings)
        {
                base.check (api_root, container, file_path, reporter, settings);
-               reporter.simple_warning ("%s: %s: @deprecated: warning: @deprecated is deprecated. Use 
[Deprecated]",
-                                                                file_path, container.get_full_name ());
+               reporter.simple_warning ("%s: %s: @deprecated".printf (file_path, container.get_full_name ()),
+                                                                "@deprecated is deprecated. Use 
[Deprecated]");
        }
 
        public override void accept (ContentVisitor visitor) {
diff --git a/src/libvaladoc/taglets/tagletinheritdoc.vala b/src/libvaladoc/taglets/tagletinheritdoc.vala
index 1f32bad..6e9aa43 100644
--- a/src/libvaladoc/taglets/tagletinheritdoc.vala
+++ b/src/libvaladoc/taglets/tagletinheritdoc.vala
@@ -142,8 +142,8 @@ public class Valadoc.Taglets.InheritDoc : InlineTaglet {
                }
 
                if (separator is Paragraph == false || separator.parent is Comment == false) {
-                       reporter.simple_error ("%s: %s: @inheritDoc: error: Parent documentation can't be 
copied to this location.",
-                                                                  file_path, container.get_full_name ());
+                       reporter.simple_error ("%s: %s: @inheritDoc".printf (file_path, 
container.get_full_name ()),
+                                                                  "Parent documentation can't be copied to 
this location.");
                        return ;
                }
 
diff --git a/src/libvaladoc/taglets/tagletlink.vala b/src/libvaladoc/taglets/tagletlink.vala
index 990fe26..b489a58 100644
--- a/src/libvaladoc/taglets/tagletlink.vala
+++ b/src/libvaladoc/taglets/tagletlink.vala
@@ -117,8 +117,8 @@ public class Valadoc.Taglets.Link : InlineTaglet {
 
                if (_symbol == null && symbol_name != "main") {
                        string node_segment = (container is Api.Package)? "" : container.get_full_name () + 
": ";
-                       reporter.simple_warning ("%s: %s link: warning: %s does not exist",
-                                                                        file_path, node_segment, 
symbol_name);
+                       reporter.simple_warning ("%s: %s link".printf (file_path, node_segment),
+                                                                        "`%s' does not exist", symbol_name);
                }
 
                base.check (api_root, container, file_path, reporter, settings);
diff --git a/src/libvaladoc/taglets/tagletparam.vala b/src/libvaladoc/taglets/tagletparam.vala
index e6e5cd0..651a9ed 100644
--- a/src/libvaladoc/taglets/tagletparam.vala
+++ b/src/libvaladoc/taglets/tagletparam.vala
@@ -57,8 +57,8 @@ public class Valadoc.Taglets.Param : BlockContent, Taglet, Block {
                if (container is Api.Callable) {
                        implicit_return_array_length = ((Api.Callable) 
container).implicit_array_length_cparameter_name;
                } else {
-                       reporter.simple_warning ("%s: %s: @param: warning: @param used outside 
method/delegate/signal context",
-                                                                        file_path, container.get_full_name 
());
+                       reporter.simple_warning ("%s: %s: @param".printf (file_path, container.get_full_name 
()),
+                                                                        "@param used outside 
method/delegate/signal context");
                        base.check (api_root, container, file_path, reporter, settings);
                        return ;
                }
@@ -112,11 +112,11 @@ public class Valadoc.Taglets.Param : BlockContent, Taglet, Block {
 
                if (this.parameter == null) {
                        if (is_implicit) {
-                               reporter.simple_note ("%s: %s: @param: warning: Implicit parameter `%s' 
exposed in documentation",
-                                                                         file_path, container.get_full_name 
(), parameter_name);
+                               reporter.simple_note ("%s: %s: @param".printf (file_path, 
container.get_full_name ()),
+                                                                         "Implicit parameter `%s' exposed in 
documentation", parameter_name);
                        } else if (!is_c_self_param) {
-                               reporter.simple_warning ("%s: %s: @param: warning: Unknown parameter `%s'",
-                                                                                file_path, 
container.get_full_name (), parameter_name);
+                               reporter.simple_warning ("%s: %s: @param".printf (file_path, 
container.get_full_name ()),
+                                                                                "Unknown parameter `%s'", 
parameter_name);
                        }
                }
 
diff --git a/src/libvaladoc/taglets/tagletreturn.vala b/src/libvaladoc/taglets/tagletreturn.vala
index 50d3adb..ef3e4ec 100644
--- a/src/libvaladoc/taglets/tagletreturn.vala
+++ b/src/libvaladoc/taglets/tagletreturn.vala
@@ -41,13 +41,13 @@ public class Valadoc.Taglets.Return : BlockContent, Taglet, Block {
                } else if (container is Api.Callable) {
                        type_ref = ((Api.Callable) container).return_type;
                } else {
-                       reporter.simple_warning ("%s: %s: @return: warning: @return used outside 
method/delegate/signal context",
-                                                                        file_path, container.get_full_name 
());
+                       reporter.simple_warning ("%s: %s: @return".printf (file_path, container.get_full_name 
()),
+                                                                        "@return used outside 
method/delegate/signal context");
                }
 
                if (type_ref != null && type_ref.data_type == null && !creation_method) {
-                       reporter.simple_warning ("%s: %s: @return: warning: Return description declared for 
void function",
-                                                                        file_path, container.get_full_name 
());
+                       reporter.simple_warning ("%s: %s: @return".printf (file_path, container.get_full_name 
()),
+                                                                        "Return description declared for 
void function");
                }
 
                base.check (api_root, container, file_path, reporter, settings);
diff --git a/src/libvaladoc/taglets/tagletsee.vala b/src/libvaladoc/taglets/tagletsee.vala
index 7ac5666..1e096fd 100644
--- a/src/libvaladoc/taglets/tagletsee.vala
+++ b/src/libvaladoc/taglets/tagletsee.vala
@@ -53,8 +53,8 @@ public class Valadoc.Taglets.See : ContentElement, Taglet, Block {
 
                if (symbol == null) {
                        // TODO use ContentElement's source reference
-                       reporter.simple_warning ("%s: %s: @see: warning: %s does not exist",
-                                                                        file_path, container.get_full_name 
(), symbol_name);
+                       reporter.simple_warning ("%s: %s: @see".printf (file_path, container.get_full_name 
()),
+                                                                        "`%s' does not exist", symbol_name);
                }
        }
 
diff --git a/src/libvaladoc/taglets/tagletthrows.vala b/src/libvaladoc/taglets/tagletthrows.vala
index cfbb098..6d3631c 100644
--- a/src/libvaladoc/taglets/tagletthrows.vala
+++ b/src/libvaladoc/taglets/tagletthrows.vala
@@ -48,8 +48,8 @@ public class Valadoc.Taglets.Throws : BlockContent, Taglet, Block {
        {
                // context check:
                if (container is Api.Method == false && container is Api.Delegate == false) {
-                       reporter.simple_warning ("%s: %s: @throws: warning: @throws used outside 
method/delegate context",
-                                                                        file_path, container.get_full_name 
());
+                       reporter.simple_warning ("%s: %s: @throws".printf (file_path, container.get_full_name 
()),
+                                                                        "@throws used outside 
method/delegate context");
                        base.check (api_root, container, file_path, reporter, settings);
                        return ;
                }
@@ -59,8 +59,8 @@ public class Valadoc.Taglets.Throws : BlockContent, Taglet, Block {
                error_domain = api_root.search_symbol_str (container, error_domain_name);
                if (error_domain == null) {
                        // TODO use ContentElement's source reference
-                       reporter.simple_error ("%s: %s: @throws: error: %s does not exist",
-                                                                  file_path, container.get_full_name (), 
error_domain_name);
+                       reporter.simple_error ("%s: %s: @throws".printf (file_path, container.get_full_name 
()),
+                                                                  "`%s' does not exist", error_domain_name);
                        base.check (api_root, container, file_path, reporter, settings);
                        return ;
                }
@@ -83,8 +83,8 @@ public class Valadoc.Taglets.Throws : BlockContent, Taglet, Block {
                        }
                }
                if (report_warning) {
-                       reporter.simple_warning ("%s: %s: @throws: warning: %s does not exist in exception 
list",
-                                                                        file_path, container.get_full_name 
(), error_domain_name);                     
+                       reporter.simple_warning ("%s: %s: @throws".printf (file_path, container.get_full_name 
()),
+                                                                        "`%s' does not exist in exception 
list", error_domain_name);
                }
 
                base.check (api_root, container, file_path, reporter, settings);
diff --git a/src/valadoc/valadoc.vala b/src/valadoc/valadoc.vala
index 9d7a982..25dafc2 100644
--- a/src/valadoc/valadoc.vala
+++ b/src/valadoc/valadoc.vala
@@ -29,6 +29,8 @@ using Gee;
 
 
 public class ValaDoc : Object {
+       private const string DEFAULT_COLORS = 
"error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01";
+
        private static string wikidirectory = null;
        private static string pkg_version = null;
        private static string docletpath = null;
@@ -49,6 +51,7 @@ public class ValaDoc : Object {
        private static bool _private = false;
        private static bool version = false;
 
+       private static bool disable_diagnostic_colors = false;
        private static bool verbose = false;
        private static bool force = false;
 
@@ -72,6 +75,8 @@ public class ValaDoc : Object {
        private static string[] tsources;
        [CCode (array_length = false, array_null_terminated = true)]
        private static string[] packages;
+       [CCode (array_length = false, array_null_terminated = true)]
+       private static string[] alternative_ressource_dirs;
        static string target_glib;
 
        private const GLib.OptionEntry[] options = {
@@ -93,6 +98,7 @@ public class ValaDoc : Object {
 
                { "importdir", 0, 0, OptionArg.FILENAME_ARRAY, ref import_directories, "Look for external 
documentation in DIRECTORY", "DIRECTORY..." },
                { "import", 0, 0, OptionArg.STRING_ARRAY, ref import_packages, "Include binding for PACKAGE", 
"PACKAGE..." },
+               { "alternative-ressource-dir", 0, 0, OptionArg.STRING_ARRAY, ref alternative_ressource_dirs, 
"Alternative ressource directories", "DIRECTORY..." },
 
                { "wiki", 0, 0, OptionArg.FILENAME, ref wikidirectory, "Wiki directory", "DIRECTORY" },
 
@@ -113,6 +119,7 @@ public class ValaDoc : Object {
 
                { "force", 0, 0, OptionArg.NONE, ref force, "force", null },
                { "verbose", 0, 0, OptionArg.NONE, ref verbose, "Show all warnings", null },
+               { "no-color", 0, 0, OptionArg.NONE, ref disable_diagnostic_colors, "Disable colored output", 
null },
                { "target-glib", 0, 0, OptionArg.STRING, ref target_glib, "Target version of glib for code 
generation", "MAJOR.MINOR" },
                { "", 0, 0, OptionArg.FILENAME_ARRAY, ref tsources, null, "FILE..." },
 
@@ -172,7 +179,7 @@ public class ValaDoc : Object {
 
                doclet = modules.create_doclet (pluginpath);
                if (doclet == null) {
-                       reporter.simple_error ("error: failed to load doclet");
+                       reporter.simple_error (null, "failed to load doclet");
                        return null;
                }
 
@@ -185,7 +192,7 @@ public class ValaDoc : Object {
 
                driver = modules.create_driver (pluginpath);
                if (driver == null) {
-                       reporter.simple_error ("error: failed to load driver");
+                       reporter.simple_error (null, "failed to load driver");
                        return null;
                }
 
@@ -235,6 +242,8 @@ public class ValaDoc : Object {
                settings.profile = profile;
                settings.defines = defines;
 
+               settings.alternative_ressource_dirs = alternative_ressource_dirs;
+
 
                // load plugins:
                Doclet? doclet = null;
@@ -304,23 +313,32 @@ public class ValaDoc : Object {
                        opt_context.add_main_entries (options, null);
                        opt_context.parse (ref args);
                } catch (OptionError e) {
-                       reporter.simple_error ("error: %s", e.message);
+                       reporter.simple_error (null, "%s", e.message);
                        stdout.printf ("Run '%s --help' to see a full list of available command line 
options.\n", args[0]);
                        return quit (reporter);
                }
 
+               if (disable_diagnostic_colors == false) {
+                       unowned string env_colors = Environment.get_variable ("VALA_COLORS");
+                       if (env_colors != null) {
+                               reporter.set_colors (env_colors);
+                       } else {
+                               reporter.set_colors (DEFAULT_COLORS);
+                       }
+               }
+
                if (version) {
                        stdout.printf ("Valadoc %s\n", Config.version);
                        return 0;
                }
 
                if (directory == null) {
-                       reporter.simple_error ("error: No output directory specified.");
+                       reporter.simple_error (null, "No output directory specified.");
                        return quit (reporter);
                }
 
                if (!check_pkg_name ()) {
-                       reporter.simple_error ("error: File already exists");
+                       reporter.simple_error (null, "File already exists");
                        return quit (reporter);
                }
 
@@ -328,28 +346,38 @@ public class ValaDoc : Object {
                        if (force == true) {
                                bool tmp = remove_directory (directory);
                                if (tmp == false) {
-                                       reporter.simple_error ("error: Can't remove directory.");
+                                       reporter.simple_error (null, "Can't remove directory.");
                                        return quit (reporter);
                                }
                        } else {
-                               reporter.simple_error ("error: File already exists");
+                               reporter.simple_error (null, "File already exists");
                                return quit (reporter);
                        }
                }
 
                if (wikidirectory != null) {
                        if (!FileUtils.test(wikidirectory, FileTest.IS_DIR)) {
-                               reporter.simple_error ("error: Wiki-directory does not exist.");
+                               reporter.simple_error (null, "Wiki-directory does not exist.");
                                return quit (reporter);
                        }
                }
 
+               foreach (unowned string dir in alternative_ressource_dirs) {
+                       if (!FileUtils.test(dir, FileTest.IS_DIR)) {
+                               reporter.simple_error (null, "alternative ressource directory '%s' does not 
exist.".printf (dir));
+                               return quit (reporter);
+                       }
+               }
+               if (reporter.errors > 0) {
+                       return quit (reporter);
+               }
+
                if (gir_name != null) {
                        long gir_len = gir_name.length;
                        int last_hyphen = gir_name.last_index_of_char ('-');
 
                        if (last_hyphen == -1 || !gir_name.has_suffix (".gir")) {
-                               reporter.simple_error ("error: GIR file name `%s' is not well-formed, 
expected NAME-VERSION.gir", gir_name);
+                               reporter.simple_error (null, "GIR file name '%s' is not well-formed, expected 
NAME-VERSION.gir", gir_name);
                                return quit (reporter);
                        }
 
@@ -358,7 +386,7 @@ public class ValaDoc : Object {
                        gir_version.canon ("0123456789.", '?');
 
                        if (gir_namespace == "" || gir_version == "" || !gir_version[0].isdigit () || 
gir_version.contains ("?")) {
-                               reporter.simple_error ("error: GIR file name `%s' is not well-formed, 
expected NAME-VERSION.gir", gir_name);
+                               reporter.simple_error (null, "GIR file name '%s' is not well-formed, expected 
NAME-VERSION.gir", gir_name);
                                return quit (reporter);
                        }
 
@@ -372,11 +400,12 @@ public class ValaDoc : Object {
                        }
 
                        if (report_warning == true) {
-                               reporter.simple_error ("error: No source file specified to be compiled to 
gir.");
+                               reporter.simple_error (null, "No source file specified to be compiled to 
gir.");
                                return quit (reporter);
                        }
                }
 
+
                var valadoc = new ValaDoc( );
                return valadoc.run (reporter);
        }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]