mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 11:25:27 +00:00
Improve indentation for doc comments
Doc comments are now split at their source, as a first step in normalizing their indentation between VS and MD.
This commit is contained in:
parent
d126d25215
commit
c1cb70d215
|
@ -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<string>();
|
||||
if (docfiles.ContainsKey(docfile))
|
||||
{
|
||||
doc = Processor.ProcessFile(docfiles[docfile]);
|
||||
docs.AddRange(Processor.ProcessFile(docfiles[docfile]));
|
||||
}
|
||||
if (doc == null)
|
||||
if (docs.Count == 0)
|
||||
{
|
||||
doc = "/// <summary></summary>";
|
||||
docs.Add("/// <summary></summary>");
|
||||
}
|
||||
|
||||
int summary_start = doc.IndexOf("<summary>") + "<summary>".Length;
|
||||
int summary_start = docs[0].IndexOf("<summary>") + "<summary>".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,11 +419,14 @@ 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);
|
||||
}
|
||||
|
||||
foreach (var doc in docs)
|
||||
{
|
||||
sw.WriteLine(doc);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("[Warning] Error processing file {0}: {1}", docfile, e.ToString());
|
||||
|
|
|
@ -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<string>();
|
||||
if (docfiles.ContainsKey(docfile))
|
||||
{
|
||||
doc = Processor.ProcessFile(docfiles[docfile]);
|
||||
docs.AddRange(Processor.ProcessFile(docfiles[docfile]));
|
||||
}
|
||||
if (doc == null)
|
||||
if (docs.Count == 0)
|
||||
{
|
||||
doc = "/// <summary></summary>";
|
||||
docs.Add("/// <summary></summary>");
|
||||
}
|
||||
|
||||
int summary_start = doc.IndexOf("<summary>") + "<summary>".Length;
|
||||
int summary_start = docs[0].IndexOf("<summary>") + "<summary>".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,11 +726,14 @@ 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);
|
||||
}
|
||||
|
||||
foreach (var doc in docs)
|
||||
{
|
||||
sw.WriteLine(doc);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("[Warning] Error processing file {0}: {1}", docfile, e.ToString());
|
||||
|
|
|
@ -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 <!-- eqn: :--> 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, "<![CDATA[" + eqn_substring + "]]>");
|
||||
text = text.Insert(m.Index, "<![CDATA[" + eqn_substring + "]]>");
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<string>();
|
||||
if (docfiles.ContainsKey(docfile))
|
||||
{
|
||||
doc = Processor.ProcessFile(docfiles[docfile]);
|
||||
docs.AddRange(Processor.ProcessFile(docfiles[docfile]));
|
||||
}
|
||||
if (doc == null)
|
||||
if (docs.Count == 0)
|
||||
{
|
||||
doc = "/// <summary></summary>";
|
||||
docs.Add("/// <summary></summary>");
|
||||
}
|
||||
|
||||
int summary_start = doc.IndexOf("<summary>") + "<summary>".Length;
|
||||
int summary_start = docs[0].IndexOf("<summary>") + "<summary>".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,11 +377,14 @@ 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);
|
||||
}
|
||||
|
||||
foreach (var doc in docs)
|
||||
{
|
||||
sw.WriteLine(doc);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("[Warning] Error processing file {0}: {1}", docfile, e.ToString());
|
||||
|
|
Loading…
Reference in a new issue