public HtmlDocument ArticleList_Catchup_SubjectGroup_HtmlDocument() { string catchup_SubjectGroup_HtmlDocument = $"{baseTestDataLocation}.ArticleList_Catchup_SubjectGroup_TestHtmlData.html"; doc.LoadHtml(DocReader.ReadDocument(catchup_SubjectGroup_HtmlDocument)); return(doc); }
public bool UpdateTrans(int id, Translate trans) { var success = false; if (trans != null) { using (var scope = new TransactionScope()) { var dbtrans = _unitOfWork.TransRepository.Get(id); if (dbtrans != null) { dbtrans.title = trans.title; dbtrans.update_date = trans.update_date; dbtrans.decription = trans.decription; dbtrans.src_lang = trans.src_lang; dbtrans.dest_lang = trans.dest_lang; dbtrans.translate_status = trans.translate_status; dbtrans.end_date = trans.end_date; dbtrans.id_translator = trans.id_translator; dbtrans.id_type = trans.id_type; dbtrans.link_customer = trans.link_customer; dbtrans.link_translator = trans.link_translator; dbtrans.translate_status = trans.translate_status; int pricecount = DocReader.ReadDoc(trans.link_customer); dbtrans.price = Convert.ToDecimal(pricecount); _unitOfWork.TransRepository.Update(dbtrans); _unitOfWork.Save(); scope.Complete(); success = true; } } } return(success); }
public static string ArticleListRawHtml(bool includeAbstract) { string no_abstractResourceName = "Scraper.UnitTests.Service.TestData.ArticleList_WithoutAbstract_TestHtmlData.html"; string with_abstractResourceName = "Scraper.UnitTests.Service.TestData.ArticleList_WithAbstract_TestHtmlData.html"; return(DocReader.ReadDocument(includeAbstract ? with_abstractResourceName : no_abstractResourceName)); }
/// <summary> /// Parses through Accord.NET XML documentation files and generate XAML code for some /// selected types of documentation entries, such as Summary, Remarks and Examples. /// </summary> /// private static Dictionary <string, DocumentationViewModel> GetDocumentation(Assembly assembly) { AssemblyMembers members = DocReader.Read(assembly); var visitor = new ClassToXamlVisitor(members.IdMap); members.Accept(visitor); return(visitor.Texts); }
public async Task RipDoc() { Log.Logger = new LoggerConfiguration().WriteTo.Console().CreateLogger(); var docReader = new DocReader(); await docReader.GetDoc(); }
private void ReadComments(Assembly assembly, string filename) { if (File.Exists(filename)) { var doc = DocReader.Read(assembly, filename); doc.Accept(new CommentsVisitor(this)); } }
public void EnsureNoDocumentationIsEmpty() { var assembly = typeof(Endpoint).Assembly; var path = AppContext.BaseDirectory + Path.GetFileName(assembly.Location); var assemblyMembers = DocReader.Read(assembly, Path.ChangeExtension(path, "xml")); var list = GetListOfMissingDocs(assemblyMembers).ToList(); if (list.Any()) { var errors = string.Join(Environment.NewLine, list); throw new Exception($"Some members have empty documentation or have a sentence that does not end with a period:{Environment.NewLine}{errors}"); } }
public static void Generate(string assemblyFile, string docdir) { if (assemblyFile == null) { throw new ArgumentNullException("assemblyFile"); } if (assemblyFile.Length == 0) { throw new ArgumentException("assemblyFile is empty."); } if (docdir == null) { throw new ArgumentNullException("docdir"); } if (docdir.Length == 0) { throw new ArgumentException("docdir is empty."); } var directory = Path.GetFullPath(docdir); assemblyFile = Path.GetFullPath(assemblyFile); Directory.SetCurrentDirectory(Path.GetDirectoryName(assemblyFile)); if (!File.Exists(assemblyFile)) { // Exit early, not found return; } var assembly = Assembly.LoadFrom(assemblyFile); Directory.CreateDirectory(directory); try { var members = DocReader.Read(assembly); var oldWriter = Console.Out; var visitor = new TypeVisitor(directory); members.Accept(visitor); visitor.Finish(); using ( var writer = new StreamWriter( Path.Combine(directory, "APIDocs.md"), false, Encoding.UTF8)) { var visitor2 = new SummaryVisitor(writer); members.Accept(visitor2); visitor2.Finish(); } } catch (IOException ex) { Console.WriteLine(ex.Message); return; } }
public void EnsureNoDocumentationIsEmpty() { var assembly = typeof(Endpoint).Assembly; var codeBase = assembly.CodeBase; var uri = new UriBuilder(codeBase); var path = Uri.UnescapeDataString(uri.Path); var assemblyMembers = DocReader.Read(assembly, Path.ChangeExtension(path, "xml")); var list = GetListOfMissingDocs(assemblyMembers).ToList(); if (list.Any()) { var errors = string.Join(Environment.NewLine, list); throw new Exception($"Some members have empty documentation or have a sentence that does not end with a period:{Environment.NewLine}{errors}"); } }
static void Main(string[] args) { var options = new ReaderOptions() { KeepNewLinesInText = true }; var members = DocReader.Read(typeof(Template).Assembly, options); var builtinClassNames = new Dictionary <string, string>() { [nameof(ArrayFunctions)] = "array", [nameof(DateTimeFunctions)] = "date", [nameof(HtmlFunctions)] = "html", [nameof(MathFunctions)] = "math", [nameof(ObjectFunctions)] = "object", [nameof(RegexFunctions)] = "regex", [nameof(StringFunctions)] = "string", [nameof(TimeSpanFunctions)] = "timespan" }; var writer = new StreamWriter("../../../../doc/builtins.md"); writer.WriteLine(@"# Builtins This document describes the various built-in functions available in scriban. "); var visitor = new MarkdownVisitor(builtinClassNames); members.Accept(visitor); writer.WriteLine(visitor.Toc); foreach (var classWriter in visitor.ClassWriters.OrderBy(c => c.Key).Select(c => c.Value)) { writer.Write(classWriter.Head); writer.Write(classWriter.Body); } writer.WriteLine(); writer.WriteLine("> Note: This document was automatically generated from the sourcecode using `Scriban.DocGen` program"); writer.Flush(); writer.Close(); }
// POST: api/Translate public IHttpActionResult Post([FromBody] Translate value) { if (value != null & value.link_customer != null) { int pricecount = DocReader.ReadDoc(value.link_customer); Debug.WriteLine("Testprice: " + pricecount); //koli4estvo slov nahodit value.price = Convert.ToDecimal(pricecount); Debug.WriteLine("Test value price: " + value.price); int id = tservice.CreateTranslate(value); // создаем перевод уже с ценой!!!!!!!!!! if (id > 0) { value.id = id; return(Created <Translate>(Request.RequestUri + id.ToString(), value)); } else { return(Conflict()); // конфликт ??? нельзя создать если эмайл занет. } } return(BadRequest("Neverniy format dannyh! Proverj celostnostj poley.")); }
public override void VisitAttributeEntry(AttributeEntry attributeEntry) { if (attributeEntry.Name != "xml-docs") { return; } //true when running from the IDE, build/output might have not been created string configuration = null; if (Program.BuildOutputPath.Contains("src")) { //bin/Debug|Release/netcoreapp2.1 configuration = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)).Parent?.Name; return; } string XmlFile(string project) { if (configuration == null) { return(Path.Combine(Program.BuildOutputPath, project, "netstandard2.0", $"{project}.XML")); } return(Path.Combine(Program.BuildOutputPath, project, "bin", configuration, "netstandard2.0", $"{project}.XML")); } var value = attributeEntry.Value; if (string.IsNullOrEmpty(value)) { base.VisitAttributeEntry(attributeEntry); return; } var parts = value.Split(':'); var assemblyName = parts[0]; var typeName = parts[1]; string xmlDocsFile; Assembly assembly; string assemblyNamespace; //TODO: tidy this up switch (assemblyName.ToLowerInvariant()) { case "elasticsearch.net": xmlDocsFile = Path.GetFullPath(XmlFile("Elasticsearch.Net")); assembly = typeof(ElasticLowLevelClient).Assembly; assemblyNamespace = typeof(ElasticLowLevelClient).Namespace; break; default: xmlDocsFile = Path.GetFullPath(XmlFile("Nest")); assembly = typeof(ElasticClient).Assembly; assemblyNamespace = typeof(ElasticClient).Namespace; break; } // build xml documentation file on the fly if it doesn't exist if (!File.Exists(xmlDocsFile)) { var project = _projects[assemblyName]; var compilation = project.GetCompilationAsync().Result; using (var peStream = new MemoryStream()) using (var commentStream = File.Create(xmlDocsFile)) { var emitResult = compilation.Emit(peStream, null, commentStream); if (!emitResult.Success) { var failures = emitResult.Diagnostics.Where(diagnostic => diagnostic.IsWarningAsError || diagnostic.Severity == DiagnosticSeverity.Error); var builder = new StringBuilder($"Unable to emit compilation for: {assemblyName}"); foreach (var diagnostic in failures) { builder.AppendLine($"{diagnostic.Id}: {diagnostic.GetMessage()}"); } builder.AppendLine(new string('-', 30)); throw new Exception(builder.ToString()); } } } var assemblyMembers = DocReader.Read(assembly, xmlDocsFile); var type = assembly.GetType(assemblyNamespace + "." + typeName); var visitor = new XmlDocsVisitor(type); visitor.VisitAssembly(assemblyMembers); if (visitor.LabeledListItems.Any()) { var labeledList = new LabeledList(); foreach (var item in visitor.LabeledListItems.OrderBy(l => l.Label)) { labeledList.Items.Add(item); } _newDocument.Insert(_newDocument.IndexOf(attributeEntry), labeledList); } }
static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("ERROR!"); Console.WriteLine("TextScriptDocGen <out_filename.md>"); return; } string outputDocPath = args[0]; /* * var options = new ReaderOptions() * { * KeepNewLinesInText = true * }; */ var members = DocReader.Read(typeof(Template).Assembly); //, options); var builtinClassNames = new Dictionary <string, string>() { [nameof(ArrayFunctions)] = "array", [nameof(DateTimeFunctions)] = "date", [nameof(HtmlFunctions)] = "html", [nameof(MathFunctions)] = "math", [nameof(ObjectFunctions)] = "object", [nameof(RegexFunctions)] = "regex", [nameof(StringFunctions)] = "string", [nameof(TimeSpanFunctions)] = "timespan", [nameof(FileSystemFunctions)] = "fs" }; var writer = new StreamWriter(outputDocPath); string[] headText = new string[] { "Builtins", "========", "This is the reference documentation for all built-in functions that is available in text templates.", "" }; string[] footerText = new string[] { "", "************************************************************************", "", "> Last updated on {0}", "> This page is generated by a tool. Any changes will be lost on the next update cycle.", "" }; writer.WriteLine(string.Join(Environment.NewLine, headText)); var visitor = new MarkdownVisitor(builtinClassNames); members.Accept(visitor); writer.WriteLine(visitor.Toc); foreach (var classWriter in visitor.ClassWriters.OrderBy(c => c.Key).Select(c => c.Value)) { writer.Write(classWriter.Head); writer.Write(classWriter.Body); } writer.WriteLine(); writer.WriteLine(string.Format(string.Join(Environment.NewLine, footerText), DateTime.Now.ToString())); writer.Flush(); writer.Close(); }
public HtmlDocument ArticleContent_1_HtmlDocument() { doc.LoadHtml(DocReader.ReadDocument("Scraper.UnitTests.Service.TestData.ArtcleContent_1_TestData.html")); return(doc); }
public override void VisitAttributeEntry(AttributeEntry attributeEntry) { if (attributeEntry.Name != "xml-docs") { return; } var configuration = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)).Parent?.Name; string XmlFile(string xmlName) { //Elastic.Transport xml lives in Elasticsearch.Net var project = xmlName == "Elastic.Transport" ? "Elasticsearch.Net" : xmlName; if (configuration == null) { return(Path.Combine(Program.InputDirPath, project, "netstandard2.0", $"{xmlName}.xml")); } return(Path.Combine(Program.InputDirPath, project, "bin", configuration, "netstandard2.0", $"{xmlName}.xml")); } var value = attributeEntry.Value; if (string.IsNullOrEmpty(value)) { base.VisitAttributeEntry(attributeEntry); return; } var parts = value.Split(':'); var assemblyName = parts[0]; var typeName = parts[1]; string xmlDocsFile; Assembly assembly; string assemblyNamespace; //TODO: tidy this up switch (assemblyName.ToLowerInvariant()) { case "elasticsearch.net": xmlDocsFile = Path.GetFullPath(XmlFile("Elasticsearch.Net")); assembly = typeof(ElasticLowLevelClient).Assembly; assemblyNamespace = typeof(ElasticLowLevelClient).Namespace; break; case "elastic.transport": xmlDocsFile = Path.GetFullPath(XmlFile("Elastic.Transport")); assembly = typeof(CloudConnectionPool).Assembly; assemblyNamespace = typeof(CloudConnectionPool).Namespace; break; default: xmlDocsFile = Path.GetFullPath(XmlFile("Nest")); assembly = typeof(ElasticClient).Assembly; assemblyNamespace = typeof(ElasticClient).Namespace; break; } // build xml documentation file on the fly if it doesn't exist if (!File.Exists(xmlDocsFile) && _projects.ContainsKey(assemblyName)) { Console.WriteLine($"Can not find {xmlDocsFile} attempting to build"); var project = _projects[assemblyName]; var compilation = project.GetCompilationAsync().Result; using (var peStream = new MemoryStream()) using (var commentStream = File.Create(xmlDocsFile)) { var emitResult = compilation.Emit(peStream, null, commentStream); if (!emitResult.Success) { var failures = emitResult.Diagnostics.Where(diagnostic => diagnostic.IsWarningAsError || diagnostic.Severity == DiagnosticSeverity.Error); var builder = new StringBuilder($"Unable to emit compilation for: {assemblyName}"); foreach (var diagnostic in failures.Take(50)) { builder.AppendLine($"{diagnostic.Id}: {diagnostic.GetMessage()}"); } builder.AppendLine(new string('-', 30)); throw new Exception(builder.ToString()); } } } if (!File.Exists(xmlDocsFile)) { throw new Exception($"Can not find xml docs: '{xmlDocsFile}'"); } var assemblyMembers = DocReader.Read(assembly, xmlDocsFile); var type = assembly.GetType(assemblyNamespace + "." + typeName); var visitor = new XmlDocsVisitor(type); visitor.VisitAssembly(assemblyMembers); if (visitor.LabeledListItems.Any()) { var labeledList = new LabeledList(); foreach (var item in visitor.LabeledListItems .OrderBy(l => l.Label) .GroupBy(l => l.Label) .Select(x => x.First())) { labeledList.Items.Add(item); } _newDocument.Insert(_newDocument.IndexOf(attributeEntry), labeledList); } }
public void newFileOpen(string pFilePath) { this.InnerText = DocReader.GetDocumentPlainText(pFilePath); }
public static void Main(string[] args) { Console.WriteLine("Press [ENTER] to run harness code..."); Console.ReadLine(); Console.WriteLine("=================================================="); string solution = args.Length > 0 ? args[0] : Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName; StringBuilder solutionReadme = new StringBuilder(); StringBuilder solutionProjects = new StringBuilder(); List <string> contents = new List <string>(); string solutionMd = Path.Combine(solution, "solution.md"); if (File.Exists(solutionMd)) { solutionReadme.AppendLine(File.ReadAllText(solutionMd)); } foreach (string project in Directory.GetDirectories(solution)) { string projectName = project.Replace(solution, "").Substring(1); string apiXml = String.Format("{0}.xml", Path.Combine(solution, project, "bin", "debug", projectName)); string apiMd = Path.Combine(solution, project, "api.md"); string projectMd = Path.Combine(solution, project, "project.md"); string projectReadme = Path.Combine(solution, project, "readme.md"); string projectNotes = String.Empty; if (File.Exists(projectMd)) { projectNotes = File.ReadAllText(projectMd); solutionProjects.AppendLine(); solutionProjects.AppendFormat(@"<a name=""{0}""></a>", projectName); solutionProjects.AppendLine(); solutionProjects.AppendLine(projectNotes); solutionProjects.AppendLine(); solutionProjects.AppendFormat(@"* [{0} project folder](./{0}/)", projectName); solutionProjects.AppendLine(); contents.Add(projectName); } if (File.Exists(apiXml)) { DocumentMembers members = DocReader.Read(apiXml); MarkdownVisitor visitor = new MarkdownVisitor(); visitor.VisitDocument(members); Console.WriteLine(apiMd); File.WriteAllText(apiMd, visitor.Markdown); File.WriteAllText(projectReadme, projectNotes + visitor.Markdown); } } // build table of contents for projects if (contents.Count > 0) { solutionReadme.AppendLine("\n\n## Project Docs"); foreach (string project in contents) { solutionReadme.AppendLine(String.Format(@"* [{0}](#{0})", project)); } solutionReadme.AppendLine(); } solutionReadme.Append(solutionProjects); File.WriteAllText(Path.Combine(solution, "readme.md"), solutionReadme.ToString()); Console.WriteLine("=================================================="); Console.WriteLine("\nPress [ENTER] to close the harness console."); Console.ReadLine(); }