Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions docs/_docset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ subs:
serverless-short: Serverless
ece: "Elastic Cloud Enterprise"
eck: "Elastic Cloud on Kubernetes"
ech: "Elastic Cloud Hosted"
kib: "Kibana"


features:
primary-nav: false

Expand Down
14 changes: 13 additions & 1 deletion src/Elastic.Markdown/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ public record BuildContext : IDocumentationContext

public bool Force { get; init; }

public bool SkipDocumentationState { get; init; }
public bool SkipDocumentationState { get; private set; }

public bool AssemblerBuild
{
get => _assemblerBuild;
init
{
_assemblerBuild = value;
SkipDocumentationState = value;
}
}

// This property is used to determine if the site should be indexed by search engines
public bool AllowIndexing { get; init; }
Expand All @@ -41,6 +51,8 @@ public record BuildContext : IDocumentationContext
public Uri? CanonicalBaseUrl { get; init; }

private readonly string? _urlPathPrefix;
private readonly bool _assemblerBuild;

public string? UrlPathPrefix
{
get => string.IsNullOrWhiteSpace(_urlPathPrefix) ? "" : $"/{_urlPathPrefix.Trim('/')}";
Expand Down
25 changes: 13 additions & 12 deletions src/Elastic.Markdown/DocumentationGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public DocumentationGenerator(
DocumentationSet = docSet;
Context = docSet.Context;
Resolver = docSet.LinkResolver;
HtmlWriter = new HtmlWriter(DocumentationSet, _writeFileSystem, new DescriptionGenerator(), navigationHtmlWriter, legacyUrlMapper, positionalNavigation);
HtmlWriter = new HtmlWriter(DocumentationSet, _writeFileSystem, new DescriptionGenerator(), navigationHtmlWriter, legacyUrlMapper,
positionalNavigation);
_documentationFileExporter =
documentationExporter
?? docSet.EnabledExtensions.FirstOrDefault(e => e.FileExporter != null)?.FileExporter
Expand Down Expand Up @@ -97,20 +98,20 @@ public async Task<GenerationResult> GenerateAll(Cancel ctx)
{
var result = new GenerationResult();

HashSet<string> offendingFiles = [];
var outputSeenChanges = DateTimeOffset.MinValue;
if (Context.SkipDocumentationState)
DocumentationSet.ClearOutputDirectory();
else
{
var generationState = GetPreviousGenerationState();
if (Context.Force || generationState == null)
DocumentationSet.ClearOutputDirectory();
var generationState = Context.SkipDocumentationState ? null : GetPreviousGenerationState();

if (CompilationNotNeeded(generationState, out offendingFiles, out outputSeenChanges))
return result;
// clear output directory if force is true but never for assembler builds since these build multiple times to the output.
if (Context is { AssemblerBuild: false, Force: true }
// clear the output directory if force is false but generation state is null, except for assembler builds.
|| (Context is { AssemblerBuild: false, Force: false } && generationState == null))
{
_logger.LogInformation($"Clearing output directory");
DocumentationSet.ClearOutputDirectory();
}

if (CompilationNotNeeded(generationState, out var offendingFiles, out var outputSeenChanges))
return result;

_logger.LogInformation($"Fetching external links");
_ = await Resolver.FetchLinks(ctx);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public AssemblerDocumentationSet(
CookiesWin = env.GoogleTagManager.CookiesWin
},
CanonicalBaseUrl = new Uri("https://www.elastic.co"), // Always use the production URL. In case a page is leaked to a search engine, it should point to the production site.
SkipDocumentationState = true,
AssemblerBuild = true
};
BuildContext = buildContext;

Expand Down
Loading