[runtime] Disable some tests in full-aot mode which cannot be AOTed because of type...
[mono-project.git] / mcs / class / monodoc / Monodoc / providers / man-provider.cs
blob6e68626551bfbcea7c3e252da1d84b3331ddf317
1 //
2 // A provider to display man pages
3 //
4 // Authors:
5 // Johannes Roith <johannes@roith.de>
6 // Jonathan Pryor <jpryor@novell.com>
7 //
8 // (C) 2008 Novell, Inc.
10 using System;
11 using System.IO;
12 using System.Text;
13 using System.Xml;
14 using System.Linq;
15 using System.Collections.Generic;
17 namespace Monodoc.Providers
19 public class ManProvider : Provider
21 string[] tocFiles;
23 public ManProvider (string[] handbookTocFiles)
25 tocFiles = handbookTocFiles;
27 // huh...
28 if (!File.Exists (tocFiles[0]))
29 throw new FileNotFoundException (String.Format ("The table of contents, `{0}' does not exist", tocFiles[0]));
32 public override void PopulateTree (Tree tree)
34 foreach(string TocFile in tocFiles) {
35 XmlDocument doc = new XmlDocument();
36 doc.Load (TocFile);
38 XmlNodeList nodeList = doc.GetElementsByTagName("manpage");
39 Node nodeToAddChildrenTo = tree.RootNode;
40 var storage = nodeToAddChildrenTo.Tree.HelpSource.Storage;
42 foreach (XmlNode node in nodeList) {
44 XmlAttribute name = node.Attributes["name"];
45 XmlAttribute page = node.Attributes["page"];
47 if (name == null || page == null) continue;
49 if (!File.Exists (page.Value))
50 continue;
52 string target = "man:" + name.Value;
53 nodeToAddChildrenTo.CreateNode (name.Value, target);
55 if (File.Exists (page.Value))
56 using (var file = File.OpenRead (page.Value))
57 storage.Store (name.Value, file);
62 public override void CloseTree (HelpSource hs, Tree tree)
67 public class ManHelpSource : HelpSource
69 const string ManPrefix = "man:";
70 Dictionary<string, Node> nodesMap;
72 public ManHelpSource (string base_file, bool create) : base (base_file, create)
74 nodesMap = Tree.RootNode.ChildNodes.ToDictionary (n => n.Element);
77 // Since man always has a flat tree and rather small amount of item
78 // we store them in a dictionary
79 public override Node MatchNode (string url)
81 Node result;
82 return nodesMap.TryGetValue (url, out result) ? result : null;
85 public override DocumentType GetDocumentTypeForId (string id)
87 return id == "root:" ? DocumentType.TocXml : DocumentType.Man;
90 public override bool IsGeneratedContent (string id)
92 return id == "root:";
95 public override string GetText (string url)
97 return TreeDumper.ExportToTocXml (Tree.RootNode, "Mono Documentation Library", "Available man pages:");
100 protected override string UriPrefix {
101 get {
102 return ManPrefix;