[valadoc] libvaladoc: turn all singletons into regular classes
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] libvaladoc: turn all singletons into regular classes
- Date: Mon, 7 Feb 2011 17:38:38 +0000 (UTC)
commit f246642a83ab022e8460e4491a4dc08beff69e84
Author: Florian Brosch <flo brosch gmail com>
Date: Thu Feb 3 20:08:31 2011 +0100
libvaladoc: turn all singletons into regular classes
src/libvaladoc/html/basicdoclet.vala | 14 +++++++-------
src/libvaladoc/html/cssclassresolver.vala | 11 -----------
src/libvaladoc/html/htmlchartfactory.vala | 7 ++++---
src/libvaladoc/html/htmlrenderer.vala | 14 +++++++-------
src/libvaladoc/html/linkhelper.vala | 12 ------------
5 files changed, 18 insertions(+), 40 deletions(-)
---
diff --git a/src/libvaladoc/html/basicdoclet.vala b/src/libvaladoc/html/basicdoclet.vala
index 1519800..e32e818 100755
--- a/src/libvaladoc/html/basicdoclet.vala
+++ b/src/libvaladoc/html/basicdoclet.vala
@@ -26,11 +26,11 @@ using Valadoc.Api;
public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
+ public Html.LinkHelper linker { protected set; get; }
public Settings settings { protected set; get; }
protected Api.Tree tree;
protected HtmlRenderer _renderer;
protected Html.MarkupWriter writer;
- protected Html.LinkHelper linker;
protected Html.CssClassResolver cssresolver;
protected Charts.Factory image_factory;
@@ -95,15 +95,15 @@ public abstract class Valadoc.Html.BasicDoclet : Api.Visitor, Doclet {
private const string css_style_content = "site_content";
private const string css_style_body = "site_body";
- construct {
- this.cssresolver = CssClassResolver.get_instance ();
- this.linker = LinkHelper.get_instance ();
- }
-
public virtual void process (Settings settings, Api.Tree tree) {
- this.image_factory = new SimpleChartFactory (settings);
this.settings = settings;
this.tree = tree;
+
+ this.cssresolver = new CssClassResolver ();
+ this.linker = new LinkHelper ();
+
+ _renderer = new HtmlRenderer (settings, this.linker, this.cssresolver);
+ this.image_factory = new SimpleChartFactory (settings, linker);
}
diff --git a/src/libvaladoc/html/cssclassresolver.vala b/src/libvaladoc/html/cssclassresolver.vala
index 35445ba..e8961ae 100755
--- a/src/libvaladoc/html/cssclassresolver.vala
+++ b/src/libvaladoc/html/cssclassresolver.vala
@@ -25,19 +25,8 @@ using Valadoc.Api;
namespace Valadoc.Html {
public class CssClassResolver : Api.Visitor {
- private static CssClassResolver _singleton = null;
private string? css_class = null;
- private CssClassResolver () {
- }
-
- public static CssClassResolver get_instance () {
- if (_singleton == null) {
- _singleton = new CssClassResolver ();
- }
- return _singleton;
- }
-
public string resolve (Api.Node node) {
node.accept (this);
return (owned) css_class;
diff --git a/src/libvaladoc/html/htmlchartfactory.vala b/src/libvaladoc/html/htmlchartfactory.vala
index 998f516..1b63b4e 100644
--- a/src/libvaladoc/html/htmlchartfactory.vala
+++ b/src/libvaladoc/html/htmlchartfactory.vala
@@ -25,9 +25,11 @@
public class Valadoc.Html.SimpleChartFactory : Charts.SimpleFactory {
private Settings _settings;
private Api.Node _container;
+ private LinkHelper _linker;
- public SimpleChartFactory (Settings settings) {
+ public SimpleChartFactory (Settings settings, LinkHelper linker) {
_settings = settings;
+ _linker = linker;
}
public override Gvc.Graph create_graph (Api.Node item) {
@@ -40,8 +42,7 @@ public class Valadoc.Html.SimpleChartFactory : Charts.SimpleFactory {
base.configure_type (node, item);
if (_container != null) {
- var linker = LinkHelper.get_instance ();
- var link = linker.get_relative_link (_container, item, _settings);
+ var link = _linker.get_relative_link (_container, item, _settings);
if (link != null) {
node.safe_set ("URL", link, "");
}
diff --git a/src/libvaladoc/html/htmlrenderer.vala b/src/libvaladoc/html/htmlrenderer.vala
index 8fef88e..65a9a91 100755
--- a/src/libvaladoc/html/htmlrenderer.vala
+++ b/src/libvaladoc/html/htmlrenderer.vala
@@ -25,16 +25,16 @@ using Valadoc.Content;
public class Valadoc.Html.HtmlRenderer : ContentRenderer {
- protected BasicDoclet _doclet;
protected Documentation? _container;
protected unowned MarkupWriter writer;
protected Html.CssClassResolver cssresolver;
protected LinkHelper linker;
+ protected Settings settings;
- public HtmlRenderer (BasicDoclet doclet) {
- cssresolver = CssClassResolver.get_instance ();
- linker = LinkHelper.get_instance ();
- _doclet = doclet;
+ public HtmlRenderer (Settings settings, LinkHelper linker, CssClassResolver cssresolver) {
+ this.cssresolver = cssresolver;
+ this.settings = settings;
+ this.linker = linker;
}
public void set_container (Documentation? container) {
@@ -54,7 +54,7 @@ public class Valadoc.Html.HtmlRenderer : ContentRenderer {
}
private string get_url (Api.Node symbol) {
- return linker.get_relative_link (_container, symbol, _doclet.settings);
+ return linker.get_relative_link (_container, symbol, settings);
}
private void write_unresolved_symbol_link (string label) {
@@ -218,7 +218,7 @@ public class Valadoc.Html.HtmlRenderer : ContentRenderer {
public override void visit_embedded (Embedded element) {
var caption = element.caption;
- var absolute_path = Path.build_filename (_doclet.settings.path, element.package.name, "img", Path.get_basename (element.url));
+ var absolute_path = Path.build_filename (settings.path, element.package.name, "img", Path.get_basename (element.url));
var relative_path = Path.build_filename ("img", Path.get_basename (element.url));
copy_file (element.url, absolute_path);
diff --git a/src/libvaladoc/html/linkhelper.vala b/src/libvaladoc/html/linkhelper.vala
index 704742f..83e4747 100644
--- a/src/libvaladoc/html/linkhelper.vala
+++ b/src/libvaladoc/html/linkhelper.vala
@@ -25,20 +25,8 @@ using Gee;
public class Valadoc.Html.LinkHelper : Object {
- private static LinkHelper _singleton;
private Settings _settings = null;
- private LinkHelper () {
- }
-
- public static LinkHelper get_instance () {
- if (_singleton == null) {
- _singleton = new LinkHelper ();
- }
-
- return _singleton;
- }
-
public string? get_package_link (Api.Package package, Settings settings) {
if (!package.is_browsable (settings)) {
return null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]