GetDocumentSuffix() 공개 정적인 메소드

public static GetDocumentSuffix ( ) : string
리턴 string
예제 #1
0
        private void Generate(
            string sourceFilePath,
            string destinationHtmlFilePath,
            ClassifiedRange[] syntacticRanges,
            ClassifiedRange[] semanticRanges)
        {
            Log.Write(destinationHtmlFilePath);
            var sb = new StringBuilder();

            var lines       = File.ReadAllLines(sourceFilePath);
            var text        = File.ReadAllText(sourceFilePath);
            var lineCount   = lines.Length;
            var lineLengths = TextUtilities.GetLineLengths(text);

            var ranges = PrepareRanges(syntacticRanges, semanticRanges, text);

            var relativePathToRoot = Paths.CalculateRelativePathToRoot(destinationHtmlFilePath, Paths.SolutionDestinationFolder);

            var prefix = Markup.GetDocumentPrefix(Path.GetFileName(sourceFilePath), relativePathToRoot, lineCount, "ix");

            sb.Append(prefix);

            var displayName  = GetDisplayName(destinationHtmlFilePath);
            var assemblyName = "TypeScriptFiles";

            var url = "/#" + assemblyName + "/" + displayName.Replace('\\', '/');

            displayName = @"\\" + displayName;

            var file = string.Format("File: <a id=\"filePath\" class=\"blueLink\" href=\"{0}\" target=\"_top\">{1}</a><br/>", url, displayName);
            var row  = string.Format("<tr><td>{0}</td></tr>", file);

            Markup.WriteLinkPanel(s => sb.AppendLine(s), row);

            // pass a value larger than 0 to generate line numbers statically at HTML generation time
            var table = Markup.GetTablePrefix();

            sb.AppendLine(table);

            var localSymbolIdMap = new Dictionary <string, int>();

            foreach (var range in ranges)
            {
                range.lineNumber = TextUtilities.GetLineNumber(range.start, lineLengths);
                var line = TextUtilities.GetLineFromPosition(range.start, text);
                range.column   = range.start - line.Item1;
                range.lineText = text.Substring(line.Item1, line.Item2);

                GenerateRange(sb, range, destinationHtmlFilePath, localSymbolIdMap);
            }

            var suffix = Markup.GetDocumentSuffix();

            sb.AppendLine(suffix);

            var folder = Path.GetDirectoryName(destinationHtmlFilePath);

            Directory.CreateDirectory(folder);
            File.WriteAllText(destinationHtmlFilePath, sb.ToString());
        }
        private async Task GenerateHtml(StreamWriter writer)
        {
            var title     = Document.Name;
            var lineCount = Text.Lines.Count;

            // if the document is very long, pregenerate line numbers statically
            // to make the page load faster and avoid JavaScript cost
            bool pregenerateLineNumbers = IsLargeFile(lineCount);

            // pass a value larger than 0 to generate line numbers in JavaScript (to reduce HTML size)
            var prefix = Markup.GetDocumentPrefix(title, relativePathToRoot, pregenerateLineNumbers ? 0 : lineCount);

            writer.Write(prefix);
            GenerateHeader(writer.WriteLine);

            var ranges = (await classifier.Classify(Document, Text)).ToArray();

            // pass a value larger than 0 to generate line numbers statically at HTML generation time
            var table = Markup.GetTablePrefix(
                DocumentUrl,
                pregenerateLineNumbers ? lineCount : 0,
                GenerateGlyphs(ranges));

            writer.WriteLine(table);

            GeneratePre(ranges, writer, lineCount);
            var suffix = Markup.GetDocumentSuffix();

            writer.WriteLine(suffix);
        }
예제 #3
0
        public void Generate(string sourceXmlFilePath, string destinationHtmlFilePath, string solutionDestinationFolder)
        {
            Log.Write(destinationHtmlFilePath);

            this.sourceXmlFilePath       = Path.GetFullPath(sourceXmlFilePath);
            this.destinationHtmlFilePath = destinationHtmlFilePath;

            sourceText = File.ReadAllText(sourceXmlFilePath);
            var lines = File.ReadAllLines(sourceXmlFilePath);

            lineLengths = TextUtilities.GetLineLengths(sourceText);
            var lineCount = lines.Length;
            var root      = Parser.ParseText(sourceText);

            var sb = new StringBuilder();

            var relativePathToRoot = Paths.CalculateRelativePathToRoot(destinationHtmlFilePath, solutionDestinationFolder);

            var prefix = Markup.GetDocumentPrefix(Path.GetFileName(sourceXmlFilePath), relativePathToRoot, lineCount, "ix");

            sb.Append(prefix);

            var displayName  = GetDisplayName();
            var assemblyName = GetAssemblyName();

            var url = "/#" + assemblyName + "/" + displayName.Replace('\\', '/');

            var file = string.Format("File: <a id=\"filePath\" class=\"blueLink\" href=\"{0}\" target=\"_top\">{1}</a><br/>", url, displayName);
            var row  = string.Format("<tr><td>{0}</td></tr>", file);

            Markup.WriteLinkPanel(s => sb.AppendLine(s), row);

            // pass a value larger than 0 to generate line numbers statically at HTML generation time
            var table = Markup.GetTablePrefix();

            sb.AppendLine(table);

            var ranges = new List <ClassifiedRange>();

            ClassifierVisitor.Visit(
                root,
                0,
                sourceText.Length,
                (start, length, node, classification) =>
            {
                var line     = TextUtilities.GetLineFromPosition(start, sourceText);
                var lineText = sourceText.Substring(line.Item1, line.Item2);

                ranges.Add(
                    new ClassifiedRange
                {
                    Classification = classification,
                    Node           = node,
                    Text           = sourceText.Substring(start, length),
                    LineText       = lineText,
                    LineStart      = line.Item1,
                    LineNumber     = TextUtilities.GetLineNumber(start, lineLengths),
                    Start          = start,
                    Length         = length
                });
            });

            ranges = RangeUtilities.FillGaps(
                sourceText,
                ranges,
                r => r.Start,
                r => r.Length,
                (s, l, t) => new ClassifiedRange
            {
                Start  = s,
                Length = l,
                Text   = t.Substring(s, l)
            }).ToList();
            foreach (var range in ranges)
            {
                GenerateRange(range, sb);
            }

            var suffix = Markup.GetDocumentSuffix();

            sb.AppendLine(suffix);

            var folder = Path.GetDirectoryName(destinationHtmlFilePath);

            Directory.CreateDirectory(folder);
            File.WriteAllText(destinationHtmlFilePath, sb.ToString());
        }
        private string GetHtml(string sourceXmlFilePath, string destinationHtmlFilePath, string displayName)
        {
            var lines = File.ReadAllLines(sourceXmlFilePath);

            lineLengths = sourceText.GetLineLengths();
            var lineCount = lines.Length;

            var sb = new StringBuilder();

            var relativePathToRoot = Paths.CalculateRelativePathToRoot(destinationHtmlFilePath, ProjectGenerator.SolutionGenerator.SolutionDestinationFolder);

            var prefix = Markup.GetDocumentPrefix(Path.GetFileName(sourceXmlFilePath), relativePathToRoot, lineCount, "ix");

            sb.Append(prefix);

            var assemblyName = GetAssemblyName();

            var url = "/#" + assemblyName + "/" + displayName.Replace('\\', '/');

            Markup.WriteLinkPanel(
                s => sb.AppendLine(s),
                fileLink: (displayName, url),
                webAccessUrl: ProjectGenerator.GetWebAccessUrl(sourceXmlFilePath),
                projectLink: (ProjectGenerator.ProjectSourcePath, Url: "/#" + assemblyName, assemblyName));

            // pass a value larger than 0 to generate line numbers statically at HTML generation time
            var table = Markup.GetTablePrefix();

            sb.AppendLine(table);

            if (sourceText.Length > 1000000)
            {
                sb.AppendLine(Markup.HtmlEscape(sourceText));
            }
            else
            {
                var ranges = new List <ClassifiedRange>();

                var root = Parser.ParseText(sourceText);
                ClassifierVisitor.Visit(
                    root,
                    0,
                    sourceText.Length,
                    (start, length, node, classification) =>
                {
                    var line     = TextUtilities.GetLineFromPosition(start, sourceText);
                    var lineText = sourceText.Substring(line.Item1, line.Item2);

                    ranges.Add(
                        new ClassifiedRange
                    {
                        Classification = classification,
                        Node           = node,
                        Text           = sourceText.Substring(start, length),
                        LineText       = lineText,
                        LineStart      = line.Item1,
                        LineNumber     = TextUtilities.GetLineNumber(start, lineLengths),
                        Start          = start,
                        Length         = length
                    });
                });

                ranges = RangeUtilities.FillGaps(
                    sourceText,
                    ranges,
                    r => r.Start,
                    r => r.Length,
                    (s, l, t) => new ClassifiedRange
                {
                    Start  = s,
                    Length = l,
                    Text   = t.Substring(s, l)
                }).ToList();
                foreach (var range in ranges)
                {
                    GenerateRange(range, sb);
                }
            }

            var suffix = Markup.GetDocumentSuffix();

            sb.AppendLine(suffix);
            return(sb.ToString());
        }