private void ConvertDoc(string inputDoc, string rootOutputDirectory) { var outputDir = GetOutputDirectory(inputDoc, rootOutputDirectory); var outputFile = Path.Combine(outputDir, GetOuputFilename(inputDoc)); var inputFileInfo = new FileInfo(inputDoc); if (!Directory.Exists(outputDir)) { Console.WriteLine("Output Directory Doesn't Exist: '" + outputDir + "'"); return; } if (!inputFileInfo.Exists) { Console.WriteLine("Input File Doesn't Exist: '" + inputDoc + "'"); return; } var ns = ExtractNamespaceFromFile(outputFile); // we might need to convert this namespace to an explicit value if (PackageNamespaceToStandalone.TryGetValue(ns, out var standaloneNs)) { ns = standaloneNs; } // get the MD converter for the namespace var converter = _defaultConverter; if (CustomConverters.TryGetValue(ns, out var customConverter)) { converter = customConverter; } var markdown = converter.ConvertFile(inputDoc); if (JavaDocFormatters.CustomReplacers.TryGetValue(ns, out var replacers)) { foreach (var r in replacers) { markdown = r.Replace(markdown); } } var doc = new ConvertedDocument(inputFileInfo, new FileInfo(outputFile), ns, markdown); if (JavaDocFormatters.CustomProcessors.TryGetValue(ns, out var processor)) { processor(doc); } markdown = doc.Markdown; // it may have changed var fileContent = AppendYamlHeader(ns, markdown); File.WriteAllText(outputFile, fileContent, Encoding.UTF8); }
private void OnConvertDocumentText(ConvertedDocument documentConversionResponse, string data) { Test(!string.IsNullOrEmpty(documentConversionResponse.textContent)); if (!string.IsNullOrEmpty(documentConversionResponse.textContent)) { Log.Debug("ExampleDocumentConversion", "HTMLContent: {0}", documentConversionResponse.textContent); } m_DocumentConversionTextTested = true; }
private void OnConvertDocument(ConvertedDocument documentConversionResponse, string data) { if (documentConversionResponse != null) { if (!string.IsNullOrEmpty(documentConversionResponse.media_type_detected)) { Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.media_type_detected); } if (!string.IsNullOrEmpty(documentConversionResponse.source_document_id)) { Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.source_document_id); } if (!string.IsNullOrEmpty(documentConversionResponse.timestamp)) { Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.timestamp); } if (documentConversionResponse.metadata != null && documentConversionResponse.metadata.Length > 0) { Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.metadata.Length); foreach (Metadata metadata in documentConversionResponse.metadata) { Log.Debug("ExampleDocumentConversion", "metadata | name: {0}, content: {1}", metadata.name, metadata.content); } } if (documentConversionResponse.answer_units != null && documentConversionResponse.answer_units.Length > 0) { Log.Debug("ExampleDocumentConversion", "mediaTypeDetected: {0}", documentConversionResponse.answer_units.Length); foreach (AnswerUnit answerUnit in documentConversionResponse.answer_units) { Log.Debug("ExampleDocumentConversion", "answerUnit | type: {0}, title: {1}, parent_id: {2}, id: {3}, direction: {4}", answerUnit.type, answerUnit.title, answerUnit.parent_id, answerUnit.id, answerUnit.direction); if (answerUnit.content != null && answerUnit.content.Length > 0) { foreach (Content content in answerUnit.content) { Log.Debug("ExampleDocumentConversion", "content | mediaType: {0}, text: {1}", content.media_type, content.text); } } } } if (!string.IsNullOrEmpty(documentConversionResponse.htmlContent)) { Log.Debug("ExampleDocumentConversion", "HTMLContent: {0}", documentConversionResponse.htmlContent); } if (!string.IsNullOrEmpty(documentConversionResponse.textContent)) { Log.Debug("ExampleDocumentConversion", "TextContent: {0}", documentConversionResponse.textContent); } } }
private void OnConvertDocument(ConvertedDocument documentConversionResponse, Dictionary <string, object> customData) { Log.Debug("TestDoucmentConversion.OnConvertDocument()", "DocumentConversion - Convert document Response: {0}", documentConversionResponse.htmlContent); Test(documentConversionResponse != null); _convertDocumentTested = true; }
private void OnConvertDocument(ConvertedDocument documentConversionResponse, string data) { Log.Debug("ExampleDoucmentConversion", "DocumentConversion - Convert document Response: {0}", documentConversionResponse.htmlContent); _convertDocumentTested = true; }