diff --git a/Source/Bind/CSharpSpecWriter.cs b/Source/Bind/CSharpSpecWriter.cs index f7964b50..c72c2079 100644 --- a/Source/Bind/CSharpSpecWriter.cs +++ b/Source/Bind/CSharpSpecWriter.cs @@ -389,29 +389,29 @@ namespace Bind if (!docfiles.ContainsKey(docfile)) docfile = Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml"; - string doc = null; + var docs = new List(); if (docfiles.ContainsKey(docfile)) { - doc = Processor.ProcessFile(docfiles[docfile]); + docs.AddRange(Processor.ProcessFile(docfiles[docfile])); } - if (doc == null) + if (docs.Count == 0) { - doc = "/// "; + docs.Add("/// "); } - int summary_start = doc.IndexOf("") + "".Length; + int summary_start = docs[0].IndexOf("") + "".Length; string warning = "[deprecated: v{0}]"; string category = "[requires: {0}]"; if (f.Deprecated) { warning = String.Format(warning, f.DeprecatedVersion); - doc = doc.Insert(summary_start, warning); + docs[0] = docs[0].Insert(summary_start, warning); } if (f.Extension != "Core" && !String.IsNullOrEmpty(f.Category)) { category = String.Format(category, f.Category); - doc = doc.Insert(summary_start, category); + docs[0] = docs[0].Insert(summary_start, category); } else if (!String.IsNullOrEmpty(f.Version)) { @@ -419,10 +419,13 @@ namespace Bind category = String.Format(category, "v" + f.Version); else category = String.Format(category, "v" + f.Version + " and " + f.Category); - doc = doc.Insert(summary_start, category); + docs[0] = docs[0].Insert(summary_start, category); } - sw.WriteLine(doc); + foreach (var doc in docs) + { + sw.WriteLine(doc); + } } catch (Exception e) { diff --git a/Source/Bind/CppSpecWriter.cs b/Source/Bind/CppSpecWriter.cs index 7dddc71a..b9f8e6ab 100644 --- a/Source/Bind/CppSpecWriter.cs +++ b/Source/Bind/CppSpecWriter.cs @@ -696,29 +696,29 @@ typedef const char* GLstring; if (!docfiles.ContainsKey(docfile)) docfile = Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml"; - string doc = null; + var docs = new List(); if (docfiles.ContainsKey(docfile)) { - doc = Processor.ProcessFile(docfiles[docfile]); + docs.AddRange(Processor.ProcessFile(docfiles[docfile])); } - if (doc == null) + if (docs.Count == 0) { - doc = "/// "; + docs.Add("/// "); } - int summary_start = doc.IndexOf("") + "".Length; + int summary_start = docs[0].IndexOf("") + "".Length; string warning = "[deprecated: v{0}]"; string category = "[requires: {0}]"; if (f.Deprecated) { warning = String.Format(warning, f.DeprecatedVersion); - doc = doc.Insert(summary_start, warning); + docs[0] = docs[0].Insert(summary_start, warning); } if (f.Extension != "Core" && !String.IsNullOrEmpty(f.Category)) { category = String.Format(category, f.Category); - doc = doc.Insert(summary_start, category); + docs[0] = docs[0].Insert(summary_start, category); } else if (!String.IsNullOrEmpty(f.Version)) { @@ -726,10 +726,13 @@ typedef const char* GLstring; category = String.Format(category, "v" + f.Version); else category = String.Format(category, "v" + f.Version + " and " + f.Category); - doc = doc.Insert(summary_start, category); + docs[0] = docs[0].Insert(summary_start, category); } - sw.WriteLine(doc); + foreach (var doc in docs) + { + sw.WriteLine(doc); + } } catch (Exception e) { diff --git a/Source/Bind/DocProcessor.cs b/Source/Bind/DocProcessor.cs index 4c0d645a..5c3ba0ae 100644 --- a/Source/Bind/DocProcessor.cs +++ b/Source/Bind/DocProcessor.cs @@ -15,7 +15,7 @@ namespace Bind static readonly XslCompiledTransform xslt = new XslCompiledTransform(); static readonly XmlReaderSettings settings = new XmlReaderSettings(); - string Text; + string[] Text; string LastFile; public DocProcessor(string transform_file) @@ -29,19 +29,21 @@ namespace Bind // found in the comments in the docs. // Todo: Some simple MathML tags do not include comments, find a solution. // Todo: Some files include more than 1 function - find a way to map these extra functions. - public string ProcessFile(string file) + public string[] ProcessFile(string file) { + string text; + if (LastFile == file) return Text; LastFile = file; - Text = File.ReadAllText(file); + text = File.ReadAllText(file); - Match m = remove_mathml.Match(Text); + Match m = remove_mathml.Match(text); while (m.Length > 0) { - string removed = Text.Substring(m.Index, m.Length); - Text = Text.Remove(m.Index, m.Length); + string removed = text.Substring(m.Index, m.Length); + text = text.Remove(m.Index, m.Length); int equation = removed.IndexOf("eqn"); if (equation > 0) { @@ -60,24 +62,25 @@ namespace Bind } string eqn_substring = removed.Substring(eqn_start, eqn_end); - Text = Text.Insert(m.Index, ""); + text = text.Insert(m.Index, ""); } next: - m = remove_mathml.Match(Text); + m = remove_mathml.Match(text); } XmlReader doc = null; try { // The pure XmlReader is ~20x faster than the XmlTextReader. - doc = XmlReader.Create(new StringReader(Text), settings); + doc = XmlReader.Create(new StringReader(text), settings); //doc = new XmlTextReader(new StringReader(text)); using (StringWriter sw = new StringWriter()) { xslt.Transform(doc, null, sw); - Text = sw.ToString().TrimEnd('\r', '\n'); + Text = sw.ToString().Split(new char[] { '\r', '\n' }, + StringSplitOptions.RemoveEmptyEntries); return Text; } } @@ -85,7 +88,7 @@ namespace Bind { Console.WriteLine(e.ToString()); Console.WriteLine(doc.ToString()); - return String.Empty; + return new string[0]; } } } diff --git a/Source/Bind/JavaSpecWriter.cs b/Source/Bind/JavaSpecWriter.cs index f2cf258b..755174fd 100644 --- a/Source/Bind/JavaSpecWriter.cs +++ b/Source/Bind/JavaSpecWriter.cs @@ -347,29 +347,29 @@ namespace Bind if (!docfiles.ContainsKey(docfile)) docfile = Settings.FunctionPrefix + f.TrimmedName.TrimEnd(numbers) + ".xml"; - string doc = null; + var docs = new List(); if (docfiles.ContainsKey(docfile)) { - doc = Processor.ProcessFile(docfiles[docfile]); + docs.AddRange(Processor.ProcessFile(docfiles[docfile])); } - if (doc == null) + if (docs.Count == 0) { - doc = "/// "; + docs.Add("/// "); } - int summary_start = doc.IndexOf("") + "".Length; + int summary_start = docs[0].IndexOf("") + "".Length; string warning = "[deprecated: v{0}]"; string category = "[requires: {0}]"; if (f.Deprecated) { warning = String.Format(warning, f.DeprecatedVersion); - doc = doc.Insert(summary_start, warning); + docs[0] = docs[0].Insert(summary_start, warning); } if (f.Extension != "Core" && !String.IsNullOrEmpty(f.Category)) { category = String.Format(category, f.Category); - doc = doc.Insert(summary_start, category); + docs[0] = docs[0].Insert(summary_start, category); } else if (!String.IsNullOrEmpty(f.Version)) { @@ -377,10 +377,13 @@ namespace Bind category = String.Format(category, "v" + f.Version); else category = String.Format(category, "v" + f.Version + " and " + f.Category); - doc = doc.Insert(summary_start, category); + docs[0] = docs[0].Insert(summary_start, category); } - sw.WriteLine(doc); + foreach (var doc in docs) + { + sw.WriteLine(doc); + } } catch (Exception e) {