private void GenerateNamespaceDirectories(string path, NamespaceHierarchy ns) { string myPath = Path.Combine(path, ns.NamespaceName); string myNsInfoPath = Path.Combine(myPath, "_namespace.md"); Directory.CreateDirectory(myPath); FileInfo fi = new FileInfo(myNsInfoPath); if (fi.Exists && fi.Length > 0) { _logger.LogInformation("There is already nonempty namespace.md for {namespace}, not generating rest"); return; } _logger.LogInformation("Generating directory for namespace {namespace}", ns.NamespaceName); File.WriteAllText(myNsInfoPath, ""); foreach (NamespaceHierarchy sns in ns.Namespaces) { GenerateNamespaceDirectories(myPath, sns); } foreach (TypeInformation type in ns.Types) { string typeFile = Path.Combine(myPath, GetFileNameForType(type.Name)); if (!File.Exists(typeFile)) { File.WriteAllText(typeFile, ""); _logger.LogInformation("Generating file for type {type}", type.Name); } else { _logger.LogDebug("File for {type} already exists, skipping", type.Name); } } }
private void ReadNamespaceInformation(AnalyzedAssembly asm, string input, NamespaceHierarchy types, ImmutableArray <int> comments, string parent) { var fullNamespace = parent != null ? parent + "." + types.NamespaceName : types.NamespaceName; _logger.LogInformation("Processing {namespace}", fullNamespace); string path = Path.Combine(input, types.NamespaceName); FileInfo nsInfo = new FileInfo(Path.Combine(path, "_namespace.md")); if (nsInfo.Exists && nsInfo.Length > 0) { asm.Strings.Add(ProcessContent(nsInfo.FullName, "📂 Namespace " + fullNamespace, 1)); comments = comments.Add(asm.Strings.Count - 1); } types.Comment = comments.ToArray(); foreach (TypeInformation type in types.Types) { FileInfo typeInfo = new FileInfo(Path.Combine(path, GetFileNameForType(type.Name))); ImmutableArray <int> fcomments = comments; if (typeInfo.Exists && typeInfo.Length > 0) { asm.Strings.Add(ProcessContent(typeInfo.FullName, "📦 Type " + fullNamespace + "." + type.Name, 2)); fcomments = fcomments.Add(asm.Strings.Count - 1); } type.Comment = fcomments.ToArray(); } foreach (NamespaceHierarchy ns in types.Namespaces) { ReadNamespaceInformation(asm, path, ns, comments, fullNamespace); } }