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
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions docs-builder.sln
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.Legac
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.LegacyDocs.Tests", "tests\Elastic.Documentation.LegacyDocs.Tests\Elastic.Documentation.LegacyDocs.Tests.csproj", "{164F55EC-9412-4CD4-81AD-3598B57632A6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{6FAB566B-76E3-4E90-8A5C-E75B0F1E1C63}"
ProjectSection(SolutionItems) = preProject
config\versions.yml = config\versions.yml
config\assembler.yml = config\assembler.yml
config\legacy-url-mappings.yml = config\legacy-url-mappings.yml
config\navigation.yml = config\navigation.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
6 changes: 3 additions & 3 deletions docs/configure/content-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Tagged

This is the default. To get started, follow our [guide](/migration/guide/index.md) to set up the new docs folder structure and CI configuration.

Once setup ensure the repository is added to our `assembler.yml` under `references`.
Once setup ensure the repository is added to our [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml) under `references`.

For example say you want to onboard `elastic/my-repository` into the production build:

Expand All @@ -59,7 +59,7 @@ Once the repository is added, its navigation still needs to be injected into to
### Tagged

If you want to have more control over the timing of when your docs go live to production. Configure the repository
in our `assembler.yml` to have a fixed git reference (typically a branch) deploy the `current` content source to production.
in our [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml) to have a fixed git reference (typically a branch) deploy the `current` content source to production.

```yaml
references:
Expand Down Expand Up @@ -101,4 +101,4 @@ jobs:
pull-requests: write
```

1. Ensure version branches are built and publish their links ahead of time.
1. Ensure version branches are built and publish their links ahead of time.
6 changes: 3 additions & 3 deletions docs/configure/site/content.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# `assembler.yml`

The global navigation is defined in the `assembler.yml` file. This file can roughly be thought of as the V3 equivalent of conf.yaml in the asciidoc build system. This file, which writers own, allows for arbitrary nesting of `docset.yml` and `toc.yml` references. This file will live in the `elastic/docs-content` repository, but will not build or have any influence over the `docs-builder` builds in that repo.
The global navigation is defined in the [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml) file. This file can roughly be thought of as the V3 equivalent of conf.yaml in the asciidoc build system. This file, which writers own, allows for arbitrary nesting of `docset.yml` and `toc.yml` references. This file will live in the `elastic/docs-content` repository, but will not build or have any influence over the `docs-builder` builds in that repo.

The global navigation that is defined in `assembler.yml` can be composed of three main resources:
The global navigation that is defined in [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml) can be composed of three main resources:
1. Local TOC files: toc.yml files that live in the docs-content repository.
2. External TOC files: A subset of a content set (represented by a toc.yml file) that is external to the docs-content repository.
3. External content set declarations: An entire docset.yml file that is external to the docs-content repository.

The `assembler.yml` file might look something like this:
The [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml) file might look something like this:

```yaml

Expand Down
4 changes: 2 additions & 2 deletions docs/configure/site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ TBD
In both the AsciiDoctor- and V3-based system, there is site-wide configuration where you list all content sources, where to find those sources, and in what order they should be added to the site.

In the AsciiDoctor system, this all happens in one YAML file in the `/docs` repo. In the V3 system:
* Content configuration happens in the [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/src/tooling/docs-assembler/assembler.yml) file in `docs-builder`.
* Navigation configuration happens in the [`navigation.yml`](https://github.com/elastic/docs-builder/blob/main/src/tooling/docs-assembler/navigation.yml) file in `docs-builder`.
* Content configuration happens in the [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml) file in `docs-builder`.
* Navigation configuration happens in the [`navigation.yml`](https://github.com/elastic/docs-builder/blob/main/config/navigation.yml) file in `docs-builder`.

[assembler.yml](./content.md)

Expand Down
5 changes: 2 additions & 3 deletions docs/contribute/_snippets/tag-processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ Specifically for versioned products, badges will display differently when the `a

Example: {applies_to}`stack: removed 99.99`

This is computed at build time (there is a docs build every 30 minutes). The documentation team tracks and maintains released versions for these products centrally in [versions.yml](https://github.com/elastic/docs-builder/blob/main/src/Elastic.Documentation.Configuration/versions.yml).

This is computed at build time (there is a docs build every 30 minutes). The documentation team tracks and maintains released versions for these products centrally in [`versions.yml`](https://github.com/elastic/docs-builder/blob/main/config/versions.yml).
When multiple lifecycle statuses and versions are specified in the sources, several badges are shown.

:::{note}
Visuals and wording in the output documentation are subject to changes and optimizations.
:::
:::
2 changes: 1 addition & 1 deletion docs/contribute/_snippets/tagged-warning.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Some repositories use a [tagged branching strategy](/contribute/branching-strate

For detailed backporting guidance, refer to the example in [Choose the docs branching strategy for a repository](/contribute/branching-strategy.md#workflow-2-tagged).

To determine the published branches for a repository, find the repository in [assembler.yml](https://github.com/elastic/docs-builder/blob/main/src/tooling/docs-assembler/assembler.yml).
To determine the published branches for a repository, find the repository in [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml).
:::
4 changes: 2 additions & 2 deletions docs/contribute/add-repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Then, successfully run a docs build on the `main` branch. This is a requirement.

::::{step} Add the repository to the assembler and navigation configs

Edit the [assembler.yml](https://github.com/elastic/docs-builder/blob/main/src/tooling/docs-assembler/assembler.yml) file to add the repository. Refer to [assembler.yml](../configure/site/content.md) for more information.
Edit the [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml) file to add the repository. Refer to [assembler.yml](../configure/site/content.md) for more information.

For example, to add the `elastic/yadda-docs` repository:

Expand All @@ -58,7 +58,7 @@ references:
In this file, you can optionally specify custom branches to deploy docs from, depending on your preferred [branching strategy](branching-strategy.md). You might want to change your branching strategy so you can have more control over when content added for a specific release is published.
:::

Then, edit the [navigation.yml](https://github.com/elastic/docs-builder/blob/main/src/tooling/docs-assembler/navigation.yml) file to add the repository to the navigation.
Then, edit the [`navigation.yml`](https://github.com/elastic/docs-builder/blob/main/config/navigation.yml) file to add the repository to the navigation.

For example, to add the `elastic/yadda-docs` repository under **Reference**:

Expand Down
8 changes: 4 additions & 4 deletions docs/contribute/branching-strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ After it has been established that a repository should publish from a version br

1. [Add new triggers to the `docs-build` CI integration](/configure/content-sources.md#ci-configuration). Merge these changes to `main` or `master` and the intended version branches.
2. Open a PR to trigger the CI integration and confirm that the docs build.
3. Open a PR updating the [docs assembler file](https://github.com/elastic/docs-builder/blob/main/src/tooling/docs-assembler/assembler.yml):
3. Open a PR updating the [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml):
* Specify which is the `current` branch for the repository. This branch is the branch from which docs are deployed to production at [elastic.co/docs](http://elastic.co/docs).
* Specify which is the `next` branch for the repository. The branch defined as `next` publishes docs internally to [staging-website.elastic.co/docs](http://staging-website.elastic.co/docs)
* Setting this branch to the next version branch in line is a good practice to preview docs change for an upcoming version.
Expand All @@ -60,10 +60,10 @@ When you publish from specific version branches, you need to bump the version br

Add an action as part of that repo’s release process for the release manager to update this same assembler file and bump the `current` branch with each release, as appropriate. The `next` branch also needs to be bumped if it is not set to `main`.

When these releases happen, create a PR against the [assembler file](https://github.com/elastic/docs-builder/blob/main/src/tooling/docs-assembler/assembler.yml) that defines the new `current` branch, to merge on release day.
When these releases happen, create a PR against the [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml) that defines the new `current` branch, to merge on release day.

:::{tip}
Regardless of the branching strategy, you also need to update the current version in [versions.yml](https://github.com/elastic/docs-builder/blob/main/src/Elastic.Documentation.Configuration/versions.yml) as part of your release process. This version number is used in documentation variables and drives our [dynamic version badge logic](/contribute/cumulative-docs.md#how-do-these-tags-behave-in-the-output).
Regardless of the branching strategy, you also need to update the current version in [`versions.yml`](https://github.com/elastic/docs-builder/blob/main/config/versions.yml) as part of your release process. This version number is used in documentation variables and drives our [dynamic version badge logic](/contribute/cumulative-docs.md#how-do-these-tags-behave-in-the-output).
:::


Expand Down Expand Up @@ -123,7 +123,7 @@ The changes must then be backported to their relevant version branches, and no f

For example, in a situation where 9.0, 9.1, and 9.2 are already released, and the 9.3 branch has already been cut:

* The branch set as `current` in the [docs assembler](https://github.com/elastic/docs-builder/blob/625e75b35841be938a8df76a62deeee811ba52d4/src/tooling/docs-assembler/assembler.yml#L70) is 9.2.
* The branch set as `current` in the [`assembler.yml`](https://github.com/elastic/docs-builder/blob/main/config/assembler.yml) is 9.2.
* The branch set as `next` (where the content development first happens), is `main`.
* 9.4 changes are only done on the `main` branch.
* 9.3 changes are done on the `main` branch and backported to the 9.3 branch.
Expand Down
4 changes: 2 additions & 2 deletions docs/contribute/cumulative-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This tagging system is mandatory for all of the public-facing documentation. We

## How version awareness works in Docs V3

Docs V3 uses a central version config called [versions.yml](https://github.com/elastic/docs-builder/blob/main/src/Elastic.Documentation.Configuration/versions.yml), which tracks the latest released versions of our products. It also tracks the earliest version of each product documented in the Docs V3 system (the earliest available on elastic.co/docs).
Docs V3 uses a central version config called [`versions.yml`](https://github.com/elastic/docs-builder/blob/main/config/versions.yml), which tracks the latest released versions of our products. It also tracks the earliest version of each product documented in the Docs V3 system (the earliest available on elastic.co/docs).

This central version config is used in certain inline version variables, and drives our [dynamic rendering logic](#how-do-these-tags-behave-in-the-output). This logic allows us to label documentation related to unreleased versions as `planned`, continuously release documentation, and document our Serverless and {{stack}} offerings in one place.

Expand Down Expand Up @@ -142,4 +142,4 @@ We do not do date-based tagging for unversioned products.
## How do these tags behave in the output?

:::{include} /contribute/_snippets/tag-processing.md
:::
:::
2 changes: 1 addition & 1 deletion docs/syntax/version-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ can be printed in any kind of ways.

## Available versioning schemes.

This is dictated by the [versions.yml](https://github.com/elastic/docs-builder/blob/main/src/Elastic.Documentation.Configuration/versions.yml) configuration file
This is dictated by the [`versions.yml`](https://github.com/elastic/docs-builder/blob/main/config/versions.yml) configuration file

* `stack`
* `ece`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
// See the LICENSE file in the project root for more information

using System.Text.RegularExpressions;
using Elastic.Documentation.Extensions;
using YamlDotNet.Serialization;
using YamlStaticContext = Elastic.Documentation.Configuration.Serialization.YamlStaticContext;

namespace Elastic.Documentation.Configuration.Assembler;

public record AssemblyConfiguration
{
public static AssemblyConfiguration Create(ConfigurationFileProvider provider) =>
Deserialize(provider.AssemblerFile.ReadToEnd());

public static AssemblyConfiguration Deserialize(string yaml)
{
var input = new StringReader(yaml);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.IO.Abstractions;
using Microsoft.Extensions.DependencyInjection;

namespace Elastic.Documentation.Configuration;

public class ConfigurationFileProvider
{
private readonly IFileSystem _fileSystem;
private readonly string _assemblyName;

public ConfigurationFileProvider(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
_assemblyName = typeof(ConfigurationFileProvider).Assembly.GetName().Name!;
TemporaryDirectory = fileSystem.Directory.CreateTempSubdirectory("docs-builder-config");

VersionFile = CreateTemporaryConfigurationFile("versions.yml");
AssemblerFile = CreateTemporaryConfigurationFile("assembler.yml");
NavigationFile = CreateTemporaryConfigurationFile("navigation.yml");
LegacyUrlMappingsFile = CreateTemporaryConfigurationFile("legacy-url-mappings.yml");
}

private IDirectoryInfo TemporaryDirectory { get; }

public IFileInfo NavigationFile { get; }

public IFileInfo VersionFile { get; }

public IFileInfo AssemblerFile { get; }

public IFileInfo LegacyUrlMappingsFile { get; }

private IFileInfo CreateTemporaryConfigurationFile(string fileName)
{
using var stream = GetLocalOrEmbedded(fileName);
var context = stream.ReadToEnd();
var fi = _fileSystem.FileInfo.New(Path.Combine(TemporaryDirectory.FullName, fileName));
_fileSystem.File.WriteAllText(fi.FullName, context);
return fi;
}

private StreamReader GetLocalOrEmbedded(string fileName)
{
var configPath = GetLocalPath(fileName);
if (!_fileSystem.File.Exists(configPath))
return GetEmbeddedStream(fileName);
var reader = _fileSystem.File.OpenText(configPath);
return reader;
}

private StreamReader GetEmbeddedStream(string fileName)
{
var resourceName = $"{_assemblyName}.{fileName}";
var resourceStream = typeof(ConfigurationFileProvider).Assembly.GetManifestResourceStream(resourceName)!;
var reader = new StreamReader(resourceStream, leaveOpen: false);
return reader;
}

public static string LocalConfigurationDirectory => Path.Combine(Paths.WorkingDirectoryRoot.FullName, "config");

private static string GetLocalPath(string file) => Path.Combine(LocalConfigurationDirectory, file);
}

public static class ConfigurationFileProviderServiceCollectionExtensions
{
public static IServiceCollection AddConfigurationFileProvider(this IServiceCollection services,
Action<IServiceCollection, ConfigurationFileProvider> configure)
{
var provider = new ConfigurationFileProvider(new FileSystem());
_ = services.AddSingleton(provider);
configure(services, provider);
return services;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="versions.yml" />
<EmbeddedResource Include="$(SolutionRoot)\config\versions.yml" />
<EmbeddedResource Include="$(SolutionRoot)\config\assembler.yml" />
<EmbeddedResource Include="$(SolutionRoot)\config\navigation.yml" />
<EmbeddedResource Include="$(SolutionRoot)\config\legacy-url-mappings.yml" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,24 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.IO.Abstractions;
using Elastic.Documentation.Configuration.Serialization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

namespace Elastic.Documentation.Configuration.Versions;

public static class VersionsConfigurationExtensions
{
private static readonly string ResourceName = "Elastic.Documentation.Configuration.versions.yml";

public static IServiceCollection AddVersions(this IServiceCollection services)
public static VersionsConfiguration CreateVersionConfiguration(this ConfigurationFileProvider provider)
{
var assembly = typeof(VersionsConfigurationExtensions).Assembly;
using var stream = assembly.GetManifestResourceStream(ResourceName) ?? throw new FileNotFoundException(ResourceName);
using var reader = new StreamReader(stream);
var path = provider.VersionFile;

var deserializer = new StaticDeserializerBuilder(new YamlStaticContext())
.WithNamingConvention(UnderscoredNamingConvention.Instance)
.Build();

var dto = deserializer.Deserialize<VersionsConfigDto>(reader);
var dto = deserializer.Deserialize<VersionsConfigDto>(path.OpenText());

var versions = dto.VersioningSystems.ToDictionary(
kvp => ToVersioningSystemId(kvp.Key),
Expand All @@ -35,10 +30,7 @@ public static IServiceCollection AddVersions(this IServiceCollection services)
Current = ToSemVersion(kvp.Value.Current)
});
var config = new VersionsConfiguration { VersioningSystems = versions };

_ = services.AddSingleton<IOptions<VersionsConfiguration>>(new OptionsWrapper<VersionsConfiguration>(config));

return services;
return config;
}

private static VersioningSystemId ToVersioningSystemId(string id)
Expand Down
21 changes: 21 additions & 0 deletions src/Elastic.Documentation/Extensions/IFileInfoExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.IO.Abstractions;

namespace Elastic.Documentation.Extensions;

public static class IFileInfoExtensions
{
public static string ReadToEnd(this IFileInfo fileInfo)
{
fileInfo.Refresh();
if (!fileInfo.Exists)
return string.Empty;

using var stream = fileInfo.OpenRead();
using var reader = new StreamReader(stream);
return reader.ReadToEnd();
}
}
Loading
Loading