public MarkdownDocumentationGenerator( DocumentationModel documentationModel, DocumentationUrlProvider urlProvider, DocumentationOptions options = null, DocumentationResources resources = null) : base(documentationModel, urlProvider: urlProvider, options: options, resources: resources) { }
/// <summary> /// Configures the from file using the specified services /// </summary> /// <param name="services">The services</param> /// <param name="configFilePath">The config file path</param> public static void ConfigureFromFile(this IServiceCollection services, string?configFilePath = null) { var documentationOptions = new DocumentationOptions(); if (!string.IsNullOrWhiteSpace(configFilePath)) { Log.Logger.Debug("Loading config from file: '{ConfigFilePath}'", configFilePath); documentationOptions = Yaml.Deserialize <DocumentationOptions>(configFilePath); } else { Log.Logger.Verbose("No config file provided. Using default settings"); } // Convert the documentation options into a list of member specific options // For example: Class doc options, Ctor doc options, Property... // In this way we can avoid passing the entire options object to each documentation // strategy that will only receive the portion of config relevant to them documentationOptions.ToList() .ForEach(d => services.AddSingleton(d.GetType(), d)); // Add also the entire object services.AddSingleton(documentationOptions); }
/// <summary> /// Get default setting for given profile type. /// </summary> /// <param name="profile"> /// The code cleanup profile to use. /// </param> /// <param name="profileType"> /// Determine if it is a full or reformat <see cref="CodeCleanup.DefaultProfileType"/>. /// </param> public void SetDefaultSetting(CodeCleanupProfile profile, CodeCleanup.DefaultProfileType profileType) { // Default option are set in the constructors. OrderingOptions orderingOptions = new OrderingOptions(); profile.SetSetting(OrderingDescriptor, orderingOptions); LayoutOptions layoutOptions = new LayoutOptions(); profile.SetSetting(LayoutDescriptor, layoutOptions); DocumentationOptions documentationOptions = new DocumentationOptions(); profile.SetSetting(DocumentationDescriptor, documentationOptions); SpacingOptions spacingOptions = new SpacingOptions(); profile.SetSetting(SpacingDescriptor, spacingOptions); ReadabilityOptions readabilityOptions = new ReadabilityOptions(); profile.SetSetting(ReadabilityDescriptor, readabilityOptions); MaintainabilityOptions maintainabilityOptions = new MaintainabilityOptions(); profile.SetSetting(MaintainabilityDescriptor, maintainabilityOptions); }
/// <inheritdoc /> public void Configure(DocumentationOptions options) { foreach (var typeMapping in options.TypeMappings) { Mappings[typeMapping.Key] = typeMapping.Value; } }
public MarkdownDocumentationWriter( DocumentationModel documentationModel, DocumentationUrlProvider urlProvider, DocumentationOptions options = null, DocumentationResources resources = null) : base(documentationModel, urlProvider, options, resources) { _writer = MarkdownWriter.Create(new StringBuilder()); }
public void Configure(DocumentationOptions documentationOptions, IReadOnlyList <IEndPointMethodHandler> endPointMethodHandlersList) { _endPointMethodHandlersList = endPointMethodHandlersList; _exposeConfiguration = _configurationManager.GetConfiguration <ExposeConfigurations>(); _documentationOptions = documentationOptions; _apiSchemaGenerator.Configure(documentationOptions); }
public DocumentProvider( IOptions <DocumentGeneratorOptions> generatorOptions, IOptions <DocumentationOptions> options, IDocumentationProvider swaggerProvider) { _generatorOptions = generatorOptions.Value; _options = options.Value; _swaggerProvider = swaggerProvider; }
public void Configure(DocumentationOptions options) { _options = options; _stringTokenReplacementService.Configure(options); UnpackAssets(); ProcessContentPath(_options.ContentPath); }
private static int GenerateDocRoot(GenerateDocRootCommandLineOptions options) { if (!TryParseVisibility(options.Visibility, out Visibility visibility)) { return(1); } DocumentationModel documentationModel = CreateDocumentationModel(options.References, options.Assemblies, visibility); if (documentationModel == null) { return(1); } if (!TryParseIgnoredRootParts(options.IgnoredParts, out RootDocumentationParts ignoredParts)) { return(1); } var documentationOptions = new DocumentationOptions( ignoredNames: options.IgnoredNames, rootDirectoryUrl: options.RootDirectoryUrl, includeClassHierarchy: !options.NoClassHierarchy, placeSystemNamespaceFirst: !options.NoPrecedenceForSystem, markObsolete: !options.NoMarkObsolete, depth: options.Depth, ignoredRootParts: ignoredParts, omitContainingNamespaceParts: (options.OmitContainingNamespace) ? OmitContainingNamespaceParts.Root : OmitContainingNamespaceParts.None, scrollToContent: options.ScrollToContent); var generator = new MarkdownDocumentationGenerator(documentationModel, WellKnownUrlProviders.GitHub, documentationOptions); string path = options.OutputPath; WriteLine($"Documentation root is being generated to '{path}'.", Verbosity.Minimal); string heading = options.Heading; if (string.IsNullOrEmpty(heading)) { string fileName = Path.GetFileName(options.OutputPath); heading = (fileName.EndsWith(".dll", StringComparison.Ordinal)) ? Path.GetFileNameWithoutExtension(fileName) : fileName; } DocumentationGeneratorResult result = generator.GenerateRoot(heading); File.WriteAllText(path, result.Content, _defaultEncoding); WriteLine($"Documentation root successfully generated to '{path}'.", Verbosity.Minimal); return(0); }
private void SetBasePath(DocumentationOptions documentationOptions) { _basePath = _configurationManager.GetConfiguration <BasePathOptions>().Path; if (!_basePath.EndsWith('/')) { _basePath += '/'; } _baseDocumentationPath = _basePath + documentationOptions.UIBasePath.TrimStart('/'); }
public IEnumerable <StaticResource> ProvideStaticResources(DocumentationOptions options) { _options = options; _stringTokenReplacementService.Configure(options); UnpackAssets(); ProcessContentPath(_options.ContentPath); return(_fileEntries.Values); }
/// <summary> /// Process clean-up on file. /// </summary> /// <param name="projectFile"> /// The project file to process. /// </param> /// <param name="range"> /// The range marker to process. /// </param> /// <param name="profile"> /// The code cleanup settings to use. /// </param> /// <param name="canIncrementalUpdate"> /// Determines whether we can incrementally update. /// </param> /// <param name="progressIndicator"> /// The progress indicator. /// </param> public void Process( IProjectFile projectFile, IPsiRangeMarker range, CodeCleanupProfile profile, out bool canIncrementalUpdate, JB::JetBrains.Application.Progress.IProgressIndicator progressIndicator) { StyleCopTrace.In(projectFile, range, profile, progressIndicator); canIncrementalUpdate = true; if (projectFile == null) { return; } if (!this.IsAvailable(projectFile)) { return; } ISolution solution = projectFile.GetSolution(); PsiManagerImpl psiManager = PsiManagerImpl.GetInstance(solution); ICSharpFile file = psiManager.GetPsiFile(projectFile, PsiLanguageType.GetByProjectFile(projectFile)) as ICSharpFile; if (file == null) { return; } DocumentationOptions documentationOptions = profile.GetSetting(DocumentationDescriptor); LayoutOptions layoutOptions = profile.GetSetting(LayoutDescriptor); MaintainabilityOptions maintainabilityOptions = profile.GetSetting(MaintainabilityDescriptor); OrderingOptions orderingOptions = profile.GetSetting(OrderingDescriptor); ReadabilityOptions readabilityOptions = profile.GetSetting(ReadabilityDescriptor); SpacingOptions spacingOptions = profile.GetSetting(SpacingDescriptor); // Process the file for all the different Code Cleanups we have here // we do them in a very specific order. Do not change it. new ReadabilityRules().Execute(readabilityOptions, file); new MaintainabilityRules().Execute(maintainabilityOptions, file); new DocumentationRules().Execute(documentationOptions, file); new LayoutRules().Execute(layoutOptions, file); new SpacingRules().Execute(spacingOptions, file); new OrderingRules().Execute(orderingOptions, file); StyleCopTrace.Out(); }
private IEndPointMethodHandler CreateOpenApiJsonEndPoint(DocumentationOptions documentationOptions) { var path = documentationOptions.OpenApiJsonUrl; if (path.StartsWith('/')) { path = path.TrimStart('/'); } path = _baseDocumentationPath + path; var configuration = CreateEndPointMethodConfiguration(path); return(new OpenApiJsonEndPointMethodHandler(_endPointServices, configuration, _openApiGenerationService)); }
/// <summary> /// Processes all the cleanup. /// </summary> /// <param name="profile"> /// The current profile to use. /// </param> /// <param name="file"> /// The file to clean. /// </param> private void InternalProcess(CodeCleanupProfile profile, ICSharpFile file) { DocumentationOptions documentationOptions = profile.GetSetting(DocumentationDescriptor); LayoutOptions layoutOptions = profile.GetSetting(LayoutDescriptor); MaintainabilityOptions maintainabilityOptions = profile.GetSetting(MaintainabilityDescriptor); OrderingOptions orderingOptions = profile.GetSetting(OrderingDescriptor); ReadabilityOptions readabilityOptions = profile.GetSetting(ReadabilityDescriptor); SpacingOptions spacingOptions = profile.GetSetting(SpacingDescriptor); // Process the file for all the different Code Cleanups we have here // we do them in a very specific order. Do not change it. new ReadabilityRules(this.shellLocks).Execute(readabilityOptions, file); new MaintainabilityRules().Execute(maintainabilityOptions, file); new DocumentationRules().Execute(documentationOptions, file); new LayoutRules().Execute(layoutOptions, file); new SpacingRules().Execute(spacingOptions, file); new OrderingRules().Execute(orderingOptions, file); }
public static IApplicationBuilder UseDocumentation( this IApplicationBuilder app, Action <DocumentationOptions> setupAction = null) { if (setupAction == null) { // Don't pass options so it can be configured/injected via DI container instead app.UseMiddleware <DocumentationMiddleware>(); } else { // Configure an options instance here and pass directly to the middleware var options = new DocumentationOptions(); setupAction.Invoke(options); app.UseMiddleware <DocumentationMiddleware>(options); } return(app); }
public void Configure(DocumentationOptions options) { _options = options; }
/// <inheritdoc /> public void Configure(DocumentationOptions documentationOptions) { _simpleOpenApiTypeMapper.Configure(documentationOptions); }
private IEndPointMethodHandler RedirectEndPoint(DocumentationOptions documentationOptions) { var configuration = CreateEndPointMethodConfiguration(_basePath); return(new RedirectEndPointHandler(_baseDocumentationPath + "index.html", configuration, _endPointServices)); }
/// <summary> /// Initializes a new instance of the <see cref="DocumentConfigHandler" /> class /// </summary> /// <param name="logger">The logger</param> /// <param name="options">The options</param> public DocumentConfigHandler(ILogger <DocumentConfigHandler> logger, DocumentationOptions options) => (_logger, _currentOptions) = (logger, options);
private IEnumerable <IEndPointMethodHandler> CreateSwaggerStaticResourceEndPoints(DocumentationOptions documentationOptions) { foreach (var staticResource in _swaggerStaticResourceProvider.ProvideStaticResources(documentationOptions)) { var configuration = CreateEndPointMethodConfiguration(_baseDocumentationPath + staticResource.Path); yield return(new StaticResourceEndPointMethodHandler(_endPointServices, configuration, staticResource)); } }
public static IApplicationBuilder UseDocumentation([NotNull] this IApplicationBuilder app, [NotNull] IDocumentHandlerResolver documentHandlerResolver, [NotNull] DocumentationOptions options) { return(app.UseMiddleware <DocumentationMiddleware>(documentHandlerResolver, options)); }
public static IApplicationBuilder UseDocumentation([NotNull] this IApplicationBuilder app, [NotNull] DocumentationOptions options) { return(app.UseDocumentation(new DefaultDocumentHandlerResolver(), options)); }
private static int GenerateDoc(GenerateDocCommandLineOptions options) { if (options.MaxDerivedTypes < 0) { WriteLine("Maximum number of derived items must be equal or greater than 0.", ConsoleColor.Red, Verbosity.Quiet); return(1); } if (!TryParseIgnoredRootParts(options.IgnoredRootParts, out RootDocumentationParts ignoredRootParts)) { return(1); } if (!TryParseIgnoredNamespaceParts(options.IgnoredNamespaceParts, out NamespaceDocumentationParts ignoredNamespaceParts)) { return(1); } if (!TryParseIgnoredTypeParts(options.IgnoredTypeParts, out TypeDocumentationParts ignoredTypeParts)) { return(1); } if (!TryParseIgnoredMemberParts(options.IgnoredMemberParts, out MemberDocumentationParts ignoredMemberParts)) { return(1); } if (!TryParseOmitContainingNamespaceParts(options.OmitContainingNamespaceParts, out OmitContainingNamespaceParts omitContainingNamespaceParts)) { return(1); } if (!TryParseVisibility(options.Visibility, out Visibility visibility)) { return(1); } DocumentationModel documentationModel = CreateDocumentationModel(options.References, options.Assemblies, visibility, options.AdditionalXmlDocumentation); if (documentationModel == null) { return(1); } var documentationOptions = new DocumentationOptions( ignoredNames: options.IgnoredNames, preferredCultureName: options.PreferredCulture, maxDerivedTypes: options.MaxDerivedTypes, includeClassHierarchy: !options.NoClassHierarchy, placeSystemNamespaceFirst: !options.NoPrecedenceForSystem, formatDeclarationBaseList: !options.NoFormatBaseList, formatDeclarationConstraints: !options.NoFormatConstraints, markObsolete: !options.NoMarkObsolete, includeMemberInheritedFrom: !options.OmitMemberInheritedFrom, includeMemberOverrides: !options.OmitMemberOverrides, includeMemberImplements: !options.OmitMemberImplements, includeMemberConstantValue: !options.OmitMemberConstantValue, includeInheritedInterfaceMembers: options.IncludeInheritedInterfaceMembers, includeAllDerivedTypes: options.IncludeAllDerivedTypes, includeAttributeArguments: !options.OmitAttributeArguments, includeInheritedAttributes: !options.OmitInheritedAttributes, omitIEnumerable: !options.IncludeIEnumerable, depth: options.Depth, inheritanceStyle: options.InheritanceStyle, ignoredRootParts: ignoredRootParts, ignoredNamespaceParts: ignoredNamespaceParts, ignoredTypeParts: ignoredTypeParts, ignoredMemberParts: ignoredMemberParts, omitContainingNamespaceParts: omitContainingNamespaceParts, scrollToContent: options.ScrollToContent); var generator = new MarkdownDocumentationGenerator(documentationModel, WellKnownUrlProviders.GitHub, documentationOptions); string directoryPath = options.OutputPath; if (!options.NoDelete && Directory.Exists(directoryPath)) { try { Directory.Delete(directoryPath, recursive: true); } catch (IOException ex) { WriteLine(ex.ToString(), ConsoleColor.Red, Verbosity.Quiet); return(1); } } var cts = new CancellationTokenSource(); Console.CancelKeyPress += (sender, e) => { e.Cancel = true; cts.Cancel(); }; CancellationToken cancellationToken = cts.Token; WriteLine($"Documentation is being generated to '{options.OutputPath}'", Verbosity.Minimal); foreach (DocumentationGeneratorResult documentationFile in generator.Generate(heading: options.Heading, cancellationToken)) { string path = Path.Combine(directoryPath, documentationFile.FilePath); Directory.CreateDirectory(Path.GetDirectoryName(path)); WriteLine($" Save '{path}'", ConsoleColor.DarkGray, Verbosity.Detailed); File.WriteAllText(path, documentationFile.Content, _defaultEncoding); } WriteLine($"Documentation successfully generated to '{options.OutputPath}'.", Verbosity.Minimal); return(0); }
public void Configure(DocumentationOptions options) { _tokenValueProvider.Configure(options); }
/// <summary> /// Initializes a new instance of the <see cref="HumanizeFormatter" /> class /// </summary> /// <param name="options">The options</param> public HumanizeFormatter(DocumentationOptions options) => this.options = options;