~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/mono-tools/windoc/WinDoc/DocTools.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
using System;
6
6
using Monodoc;
 
7
using Monodoc.Generators;
7
8
using System.IO;
8
9
 
9
10
namespace WinDoc
10
11
{
11
 
        public class DocTools {
 
12
        public class DocTools
 
13
        {
 
14
                static IDocGenerator<string> generator = new HtmlGenerator (null);
 
15
 
12
16
                public static string GetHtml (string url, HelpSource helpSource)
13
17
                {
14
18
                        Node _;
17
21
                
18
22
                public static string GetHtml (string url, HelpSource helpSource, out Node match)
19
23
                {
20
 
                        Console.WriteLine ("Calling URL {0} with HelpSource {1}", url, helpSource == null ? "(null)" : helpSource.Name);
21
 
 
22
24
                        string htmlContent = null;
23
25
                        match = null;
24
26
                        
25
27
                        if (helpSource != null)
26
 
                                htmlContent = helpSource.GetText (url, out match);
27
 
                        if (htmlContent == null){
 
28
                                htmlContent = Program.Root.RenderUrl (url, generator, out match, helpSource);
 
29
                        if (htmlContent == null) {
28
30
                                // the displayed url have a lower case type code (e.g. t: instead of T:) which confuse monodoc
29
31
                                if (url.Length > 2 && url[1] == ':')
30
32
                                        url = char.ToUpperInvariant (url[0]) + url.Substring (1);
31
33
                                // It may also be url encoded so decode it
32
34
                                url = Uri.UnescapeDataString (url);
33
 
                                htmlContent = Program.Root.RenderUrl (url, out match);
34
 
                                if (htmlContent != null && match != null && match.tree != null){
35
 
                                        helpSource = match.tree.HelpSource;
36
 
                                }
 
35
                                htmlContent = Program.Root.RenderUrl (url, generator, out match, helpSource);
 
36
                                if (htmlContent != null && match != null && match.Tree != null)
 
37
                                        helpSource = match.Tree.HelpSource;
37
38
                        }
38
39
                        if (htmlContent == null)
39
40
                                return null;
41
42
                        var html = new StringWriter ();
42
43
                        html.Write ("<html>\n<head><title>{0}</title>", url);
43
44
                        
44
 
                        if (helpSource != null){
45
 
                if (helpSource.InlineCss != null) 
46
 
                    html.Write (" <style type=\"text/css\">{0}</style>\n", helpSource.InlineCss);
47
 
                                if (helpSource.InlineJavaScript != null)
48
 
                    html.Write ("<script type=\"text/JavaScript\">{0}</script>\n", helpSource.InlineJavaScript);
 
45
                        if (helpSource != null) {
 
46
                                if (HtmlGenerator.InlineCss != null)
 
47
                    html.Write (" <style type=\"text/css\">{0}</style>\n", HtmlGenerator.InlineCss);
 
48
                                /*if (helpSource.InlineJavaScript != null)
 
49
                    html.Write ("<script type=\"text/JavaScript\">{0}</script>\n", helpSource.InlineJavaScript);*/
49
50
            }
50
51
 
51
52
            html.Write ("</head><body>");
52
53
            html.Write (htmlContent);
53
54
            html.Write ("</body></html>\n");
54
 
                        return html.ToString ();
 
55
            return html.ToString ();
55
56
                }
56
57
        }
57
58
}