return to_docbook_id (name);
}
- public bool write (Settings settings) {
+ public bool write (Settings settings, ErrorReporter reporter) {
var xml_dir = Path.build_filename (settings.path, "xml");
DirUtils.create_with_parents (xml_dir, 0777);
var xml_file = Path.build_filename (xml_dir, "%s.xml".printf (to_docbook_id (name)));
var writer = new TextWriter (xml_file, "w");
if (!writer.open ()) {
- warning ("GtkDoc: unable to open %s for writing", writer.filename);
+ reporter.simple_error ("GtkDoc: unable to open %s for writing".printf (writer.filename));
return false;
}
- writer.write_line (to_string ());
+ writer.write_line (to_string (reporter));
writer.close ();
return true;
}
- public string to_string () {
+ public string to_string (ErrorReporter reporter) {
/* compute minimum indent for methods */
var method_indent = 0;
foreach (var method in methods) {
<programlisting>%s
</programlisting>
%s
-</refsect2>""", docbook_id, method.get_docbook_id (), method.name, method.to_string (method_indent, false), method.comment != null ? method.comment.to_docbook () : "");
+</refsect2>""", docbook_id, method.get_docbook_id (), method.name, method.to_string (method_indent, false), method.comment != null ? method.comment.to_docbook (reporter) : "");
}
builder.append ("</refsect1>");
<programlisting>%s
</programlisting>
%s
-</refsect2>""", docbook_id, sig.get_docbook_id (), sig.name, sig.to_string (signal_indent, false), sig.comment != null ? sig.comment.to_docbook () : "");
+</refsect2>""", docbook_id, sig.get_docbook_id (), sig.name, sig.to_string (signal_indent, false), sig.comment != null ? sig.comment.to_docbook (reporter) : "");
}
builder.append ("</refsect1>");
return builder.str;
}
}
-}
\ No newline at end of file
+}
{ null }
};
- public static bool parse (string[] rargs) {
+ public static bool parse (string[] rargs, ErrorReporter reporter) {
string[] args = { "gtkdoc" };
foreach (var arg in rargs) {
args += arg;
unowned string[] gtkdoc_args = args;
opt_context.parse (ref gtkdoc_args);
} catch (OptionError e) {
- warning ("GtkDoc: Error: %s", e.message);
- warning ("GtkDoc: Run '-X --help' to see a full list of available command line options.\n");
+ reporter.simple_error ("GtkDoc: Error: %s\nRun '-X --help' to see a full list of available command line options.".printf (e.message));
return false;
}
*/
public void process (Settings settings, Api.Tree tree, ErrorReporter reporter) {
this.settings = settings;
- if (!Config.parse (settings.pluginargs)) {
+ if (!Config.parse (settings.pluginargs, reporter)) {
return;
}
this.reporter = reporter;
find_files (ccomments_dir);
if (vala_headers.length <= 0) {
- warning ("GtkDoc: No vala header found");
+ reporter.simple_error ("GtkDoc: No vala header found");
return;
}
Path.build_filename (settings.path, "%s-sections.txt".printf (settings.pkg_name)));
generator = new Gtkdoc.Generator ();
- if (!generator.execute (settings, tree)) {
+ if (!generator.execute (settings, tree, reporter)) {
return;
}
private void prepare_external_c_files (Api.Tree tree, string comments_dir) {
foreach (string filename in tree.get_external_c_files ()) {
if (!copy_file (filename, Path.build_filename (comments_dir, Path.get_basename (filename)))) {
- warning ("GtkDoc: Can't copy %s", filename);
+ reporter.simple_error ("GtkDoc: Can't copy %s".printf (filename));
return ;
}
}
try {
dir = Dir.open (dirname);
} catch (Error e) {
- warning ("GtkDoc: Can't open %s: %s", settings.basedir, e.message);
+ reporter.simple_error ("GtkDoc: Can't open %s: %s".printf (settings.basedir, e.message));
return;
}
}
string[] args = { "gtkdoc-scan",
- "--module", settings.pkg_name,
- "--output-dir", output_dir,
- "--rebuild-sections", "--rebuild-types" };
+ "--module", settings.pkg_name,
+ "--output-dir", output_dir,
+ "--rebuild-sections",
+ "--rebuild-types" };
foreach (var header in headers) {
args += header;
try {
Process.spawn_sync (settings.path, args, null, SpawnFlags.SEARCH_PATH, null, null, null);
} catch (Error e) {
- warning ("gtkdoc-scan: %s", e.message);
+ reporter.simple_error ("gtkdoc-scan: %s".printf (e.message));
return false;
}
string[] pc = { "pkg-config" };
foreach (var package in tree.get_package_list()) {
- if (package.is_package && package_exists (package.name)) {
+ if (package.is_package && package_exists (package.name, reporter)) {
pc += package.name;
}
}
string cflags;
Process.spawn_sync (null, pc_cflags, null, SpawnFlags.SEARCH_PATH, null, out cflags, out stderr, out status);
if (status != 0) {
- warning ("GtkDoc: pkg-config cflags error: %s\n", stderr);
+ reporter.simple_error ("GtkDoc: pkg-config cflags error: %s".printf (stderr));
return false;
}
cflags = cflags.strip ();
string libs;
Process.spawn_sync (null, pc_libs, null, SpawnFlags.SEARCH_PATH, null, out libs, out stderr, out status);
if (status != 0) {
- warning ("GtkDoc: pkg-config libs error: %s\n", stderr);
+ reporter.simple_error ("GtkDoc: pkg-config libs error: %s".printf (stderr));
return false;
}
"--output-dir", settings.path };
string[] env = { "CFLAGS=%s %s".printf (cflags,
- Environment.get_variable ("CFLAGS") ?? ""),
- "LDFLAGS=%s %s %s".printf (libs, library,
- Environment.get_variable ("LDFLAGS") ?? ""),
- "LD_LIBRARY_PATH=%s:%s".printf (Path.get_dirname (library),
- Environment.get_variable ("LD_LIBRARY_PATH") ?? "")};
+ Environment.get_variable ("CFLAGS") ?? ""),
+ "LDFLAGS=%s %s %s".printf (libs, library,
+ Environment.get_variable ("LDFLAGS") ?? ""),
+ "LD_LIBRARY_PATH=%s:%s".printf (Path.get_dirname (library),
+ Environment.get_variable ("LD_LIBRARY_PATH") ?? "")};
foreach (var evar in Environment.list_variables()) {
if (evar != "CFLAGS" && evar != "LDFLAGS" && evar != "LD_LIBRARY_PATH")
env += "%s=%s".printf (evar, Environment.get_variable(evar));
Process.spawn_sync (settings.path, args, env, SpawnFlags.SEARCH_PATH, null, null, null);
} catch (Error e) {
- warning ("gtkdoc-scangobj: %s", e.message);
+ reporter.simple_error ("gtkdoc-scangobj: %s".printf (e.message));
return false;
}
var must_update_main_file = !FileUtils.test (main_file, FileTest.EXISTS);
var args = new string[] { "gtkdoc-mkdb",
- "--module", settings.pkg_name,
- "--source-dir", code_dir,
- "--output-format", "xml",
- "--sgml-mode",
- "--main-sgml-file", "%s-docs.xml".printf (settings.pkg_name),
- "--name-space", settings.pkg_name };
+ "--module", settings.pkg_name,
+ "--source-dir", code_dir,
+ "--output-format", "xml",
+ "--sgml-mode",
+ "--main-sgml-file", "%s-docs.xml".printf (settings.pkg_name),
+ "--name-space", settings.pkg_name };
try {
- Process.spawn_sync (settings.path, args,
- null, SpawnFlags.SEARCH_PATH, null, null, null);
+ Process.spawn_sync (settings.path, args, null, SpawnFlags.SEARCH_PATH, null, null, null);
} catch (Error e) {
- warning ("gtkdoc-mkdb: %s", e.message);
+ reporter.simple_error ("gtkdoc-mkdb: %s".printf (e.message));
return false;
}
try {
FileUtils.get_contents (main_file, out contents);
} catch (Error e) {
- warning ("GtkDoc: Error while reading main file '%s' contents: %s", main_file, e.message);
+ reporter.simple_error ("GtkDoc: Error while reading main file '%s' contents: %s".printf (main_file, e.message));
return false;
}
try {
FileUtils.set_contents (main_file, contents);
} catch (Error e) {
- warning ("GtkDoc: Error while writing main file '%s' contents: %s", main_file, e.message);
+ reporter.simple_error ("GtkDoc: Error while writing main file '%s' contents: %s".printf (main_file, e.message));
return false;
}
}
try {
Process.spawn_sync (html_dir,
- {"gtkdoc-mkhtml",
- settings.pkg_name, "../%s-docs.xml".printf (settings.pkg_name)},
- null, SpawnFlags.SEARCH_PATH, null, null, null);
+ {"gtkdoc-mkhtml",
+ settings.pkg_name, "../%s-docs.xml".printf (settings.pkg_name)},
+ null, SpawnFlags.SEARCH_PATH, null, null, null);
} catch (Error e) {
- warning ("gtkdoc-mkhtml: %s", e.message);
+ reporter.simple_error ("gtkdoc-mkhtml: %s".printf (e.message));
return false;
}
/* fix xrefs for regenerated html */
try {
Process.spawn_sync (settings.path,
- { "gtkdoc-fixxref",
- "--module", settings.pkg_name,
- "--module-dir", html_dir,
- "--html-dir", html_dir },
- null, SpawnFlags.SEARCH_PATH, null, null, null);
+ { "gtkdoc-fixxref",
+ "--module", settings.pkg_name,
+ "--module-dir", html_dir,
+ "--html-dir", html_dir },
+ null, SpawnFlags.SEARCH_PATH, null, null, null);
} catch (Error e) {
- warning ("gtkdoc-fixxref: %s", e.message);
+ reporter.simple_error ("gtkdoc-fixxref: %s".printf (e.message));
return false;
}
[ModuleInit]
public Type register_plugin (GLib.TypeModule module) {
- return typeof ( Gtkdoc.Director );
+ return typeof (Gtkdoc.Director);
}
public Gee.List<DBus.Interface> dbus_interfaces = new Gee.LinkedList<DBus.Interface>();
+ private ErrorReporter reporter;
private Settings settings;
private Gee.Map<string, FileData> files_data = new Gee.HashMap<string, FileData>();
private string current_cname;
}
}
- public bool execute (Settings settings, Api.Tree tree) {
+ public bool execute (Settings settings, Api.Tree tree, ErrorReporter reporter) {
this.settings = settings;
+ this.reporter = reporter;
tree.accept (this);
var code_dir = Path.build_filename (settings.path, "ccomments");
var sections = Path.build_filename (settings.path, "%s-sections.txt".printf (settings.pkg_name));
var sections_writer = new TextWriter (sections, "a");
if (!sections_writer.open ()) {
- warning ("GtkDoc: unable to open %s for writing", sections_writer.filename);
+ reporter.simple_error ("GtkDoc: unable to open %s for writing".printf (sections_writer.filename));
return false;
}
var cwriter = new TextWriter (Path.build_filename (code_dir, "%s.c".printf (basename)), "w");
if (!cwriter.open ()) {
- warning ("GtkDoc: unable to open %s for writing", cwriter.filename);
+ reporter.simple_error ("GtkDoc: unable to open %s for writing".printf (cwriter.filename));
return false;
}
}
private GComment create_gcomment (string symbol, Comment? comment, string[]? returns_annotations = null, bool is_dbus = false) {
- var converter = new Gtkdoc.CommentConverter (current_method_or_delegate);
+ var converter = new Gtkdoc.CommentConverter (reporter, current_method_or_delegate);
if (comment != null) {
converter.convert (comment, is_dbus);
return null;
}
- var converter = new Gtkdoc.CommentConverter (current_method_or_delegate);
+ var converter = new Gtkdoc.CommentConverter (reporter, current_method_or_delegate);
var header = new Header (name);
header.pos = pos;
set_section_comment (iface.get_filename(), iface.get_cname(), iface.documentation);
if (current_dbus_interface != null) {
- current_dbus_interface.write (settings);
+ current_dbus_interface.write (settings, reporter);
dbus_interfaces.add (current_dbus_interface);
}
set_section_comment (cl.get_filename(), cl.get_cname(), cl.documentation);
if (current_dbus_interface != null) {
- current_dbus_interface.write (settings);
+ current_dbus_interface.write (settings, reporter);
dbus_interfaces.add (current_dbus_interface);
}