-
Notifications
You must be signed in to change notification settings - Fork 32
Add support for version context variables #1560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,60 @@ | |||||||||||||||||
| # Version Variables | |||||||||||||||||
|
|
|||||||||||||||||
| Version are exposed during build using the `{{versions.VERSIONING_SCHEME}}` variable. | |||||||||||||||||
|
|
|||||||||||||||||
| For example `stack` versioning variables are exposed as `{{versions.stack}}`. | |||||||||||||||||
|
|
|||||||||||||||||
| ## Specialized Suffixes. | |||||||||||||||||
|
|
|||||||||||||||||
| Besides the current version, the following suffixes are available: | |||||||||||||||||
|
|
|||||||||||||||||
| | Version substitution | result | purpose | | |||||||||||||||||
| |--------------------------------------|-----------------------------------|-----------------------------------------| | |||||||||||||||||
| | `{{versions.stack}}` | {{version.stack}} | Current version | | |||||||||||||||||
| | `{{versions.stack.major_minor}}` | {{version.stack.major_minor}} | Current `MAJOR.MINOR` | | |||||||||||||||||
| | `{{versions.stack.major_x}}` | {{version.stack.major_x}} | Current `MAJOR.X` | | |||||||||||||||||
| | `{{versions.stack.major_component}}` | {{version.stack.major_component}} | Current major component | | |||||||||||||||||
| | `{{versions.stack.next_major}}` | {{version.stack.next_major}} | The next major version | | |||||||||||||||||
| | `{{versions.stack.next_minor}}` | {{version.stack.next_minor}} | The next minor version | | |||||||||||||||||
| | `{{versions.stack.base}}` | {{version.stack.base}} | The first version on the new doc system | | |||||||||||||||||
|
|||||||||||||||||
| current | next | format |
|---|---|---|
version.stack |
version.stack.next |
#.#.# |
version.stack.major_minor |
version.stack.next_major_minor |
#.# |
version.stack.major_x |
version.stack.next_major_x |
#.x |
version.stack.major_component |
version.stack.next_major_component |
# |
I don't have a strong opinion about versions.stack.base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
version.stack would be version.stack.current but I see your point.
I think {{version.stack.current}} might be too verbose though.
See also my comment on bases here #1560 (comment)
Mpdreamz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Mpdreamz marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
| using DotNet.Globbing; | ||
| using Elastic.Documentation.Configuration.Suggestions; | ||
| using Elastic.Documentation.Configuration.TableOfContents; | ||
| using Elastic.Documentation.Configuration.Versions; | ||
| using Elastic.Documentation.Links; | ||
| using Elastic.Documentation.Navigation; | ||
| using YamlDotNet.RepresentationModel; | ||
|
|
@@ -61,7 +62,7 @@ public record ConfigurationFile : ITableOfContentsScope | |
| Project is not null | ||
| && Project.Equals("Elastic documentation", StringComparison.OrdinalIgnoreCase); | ||
|
|
||
| public ConfigurationFile(IDocumentationContext context) | ||
| public ConfigurationFile(IDocumentationContext context, VersionsConfiguration versionsConfig) | ||
| { | ||
| _context = context; | ||
| ScopeDirectory = context.ConfigurationPath.Directory!; | ||
|
|
@@ -159,6 +160,32 @@ public ConfigurationFile(IDocumentationContext context) | |
| } | ||
| } | ||
|
|
||
| foreach (var (id, system) in versionsConfig.VersioningSystems) | ||
| { | ||
| var name = id.ToStringFast(true); | ||
| var current = system.Current; | ||
| var key = $"version.{name}"; | ||
| _substitutions[key] = system.Current; | ||
|
|
||
| key = $"version.{name}.base"; | ||
| _substitutions[key] = system.Base; | ||
|
|
||
| key = $"version.{name}.major_minor"; | ||
| _substitutions[key] = $"{current.Major:N0}.{current.Minor:N0}"; | ||
|
|
||
| key = $"version.{name}.major_x"; | ||
| _substitutions[key] = $"{current.Major:N0}.x"; | ||
|
|
||
| key = $"version.{name}.major_component"; | ||
| _substitutions[key] = $"{current.Major:N0}"; | ||
|
|
||
| key = $"version.{name}.next_minor"; | ||
| _substitutions[key] = new SemVersion(current.Major, current.Minor + 1, current.Patch, current.Prerelease, current.Metadata); | ||
|
|
||
| key = $"version.{name}.next_major"; | ||
| _substitutions[key] = new SemVersion(current.Major + 1, current.Minor, current.Patch, current.Prerelease, current.Metadata); | ||
|
||
| } | ||
|
|
||
| var toc = new TableOfContentsConfiguration(this, sourceFile, ScopeDirectory, _context, 0, ""); | ||
| TableOfContents = toc.TableOfContents; | ||
| Files = toc.Files; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in most cases I think we want the base usage to be the major_minor version. might want to make that the "core" and make a
versions.stack.patchor something insteadThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be formatted e.g
9.0.0=9.0and9.0.1would be9.0.1?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about that. I think so though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the installation instructions would need the full V.R.M but that would not be the general case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Installation instructions and download links are probably the most important use cases for me. 😬
I think I'd prefer it to be major-minor-patch if only for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think the path of least surprise is to have the base be full
V.R.M{{versions.stack}}{{versions.stack.base}}{{versions.stack.next_major}}{{versions.stack.next_minor}}Where the
V.RandV.xandVvariants can all be obtained using a*.suffix.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened #1563 as a completely new approach that allows a more generic approach to reformatting variables.
In that PR we only expose:
{{versions.stack}}{{versions.stack.base}}With operators to get a specific format e.g
{{versions.stack | M.x }}