WriteLinkPanel() public static method

public static WriteLinkPanel ( Action writeLine ) : void
writeLine Action
return void
Exemplo n.º 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());
        }
Exemplo n.º 2
0
 private void GenerateHeader(Action <string> writeLine)
 {
     Markup.WriteLinkPanel(
         writeLine,
         fileLink: (Display: documentRelativeFilePathWithoutHtmlExtension, Url: "/#" + DocumentUrl),
         webAccessUrl: projectGenerator.GetWebAccessUrl(Document.FilePath),
         projectLink: (Display: projectGenerator.ProjectSourcePath, Url: "/#" + Document.Project.AssemblyName, projectGenerator.AssemblyName));
 }
Exemplo n.º 3
0
        private string GenerateHeader(Action <string> writeLine)
        {
            string documentDisplayName = documentRelativeFilePathWithoutHtmlExtension;
            string documentUrl         = "/#" + Document.Project.AssemblyName + "/" + documentRelativeFilePathWithoutHtmlExtension.Replace('\\', '/');
            string projectDisplayName  = projectGenerator.ProjectSourcePath;
            string projectUrl          = "/#" + Document.Project.AssemblyName;

            string documentLink = string.Format("File: <a id=\"filePath\" class=\"blueLink\" href=\"{0}\" target=\"_top\">{1}</a><br/>", documentUrl, documentDisplayName);
            string projectLink  = string.Format("Project: <a id=\"projectPath\" class=\"blueLink\" href=\"{0}\" target=\"_top\">{1}</a> ({2})", projectUrl, projectDisplayName, projectGenerator.AssemblyName);

            string fileShareLink = GetFileShareLink();

            if (fileShareLink != null)
            {
                fileShareLink = Markup.A(fileShareLink, "File", "_blank");
            }
            else
            {
                fileShareLink = "";
            }

            string webLink = GetWebLink();

            if (webLink != null)
            {
                webLink = Markup.A(webLink, "Web&nbsp;Access", "_blank");
            }
            else
            {
                webLink = "";
            }

            string firstRow  = string.Format("<tr><td>{0}</td><td>{1}</td></tr>", documentLink, webLink);
            string secondRow = string.Format("<tr><td>{0}</td><td>{1}</td></tr>", projectLink, fileShareLink);

            Markup.WriteLinkPanel(writeLine, firstRow, secondRow);

            return(documentUrl);
        }
Exemplo n.º 4
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());
        }