Skip to content
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

[Docs] Update "Alert and action settings" docs to be generated from YAML source #191787

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7275ea1
[Docs test] Config settings mock-up
kilfoyle Aug 29, 2024
048cd53
Fix script to use relative rather than hard-coded paths
kilfoyle Aug 30, 2024
11d33ed
Fix up script
kilfoyle Sep 5, 2024
7d2ba0a
Add groups logic
kilfoyle Sep 6, 2024
3490fe1
fixup
kilfoyle Sep 6, 2024
ccc7327
Add readme with schema
kilfoyle Sep 11, 2024
9d9d4d1
Add example yml page and output
kilfoyle Sep 16, 2024
2ebaa99
touchup
kilfoyle Sep 16, 2024
b58f23c
touchup
kilfoyle Sep 16, 2024
66bbcd6
Remove comments from examples file
kilfoyle Sep 17, 2024
3f70764
Reformat output; no plus signs
kilfoyle Sep 18, 2024
44185e7
Fix readme, plus other stuff that I forget
kilfoyle Sep 27, 2024
a27b353
readme touchup
kilfoyle Sep 27, 2024
79aa177
readme touchup
kilfoyle Sep 27, 2024
5c419f0
Fix script & schema, add template
kilfoyle Oct 3, 2024
fbc50b1
Comment out unused settings
kilfoyle Oct 4, 2024
142d232
Fix examples, intros, etc.
kilfoyle Oct 4, 2024
b19f09d
Add alert and action settings
kilfoyle Oct 4, 2024
58c1564
Merge branch 'main' into generate-settings-testing-02
kilfoyle Oct 4, 2024
b544771
Fix parent files
kilfoyle Oct 4, 2024
3c839cc
Remove old files, examples, etc.
kilfoyle Oct 7, 2024
aa630ec
fixup
kilfoyle Oct 7, 2024
adaac1a
Merge branch 'main' into generate-settings-testing-02
kilfoyle Oct 7, 2024
0435719
Merge branch 'main' into generate-settings-testing-02
kilfoyle Oct 9, 2024
2a04536
Fix readme; add changes from Kibana PRs 195308, 195320
kilfoyle Oct 9, 2024
b91b149
Merge branch 'main' into generate-settings-testing-02
kilfoyle Oct 9, 2024
afaf62b
Add top of file warnings
kilfoyle Oct 9, 2024
5c31ac4
Add platform-docs as codeowners for setting-gen directory
kilfoyle Oct 9, 2024
df17b44
Merge branch 'main' into generate-settings-testing-02
kilfoyle Oct 10, 2024
5efed75
Add setting update from Kibana #189027
kilfoyle Oct 23, 2024
c9bb65e
Merge branch 'main' into generate-settings-testing-02
kilfoyle Oct 23, 2024
ae43bf4
Merge branch 'main' into generate-settings-testing-02
kilfoyle Oct 28, 2024
0ff8363
Merge branch 'main' into generate-settings-testing-02
kilfoyle Oct 30, 2024
8c8f182
Merge branch 'main' into generate-settings-testing-02
kilfoyle Nov 4, 2024
642b207
Add settings changes from Kibana #198435
kilfoyle Nov 4, 2024
8230849
Merge branch 'main' into generate-settings-testing-02
kilfoyle Nov 4, 2024
f2d494b
Remove collapsible sections
kilfoyle Nov 21, 2024
86d0679
Remove 'inference-action-type' to resolve conflict with Lisa's 198633
kilfoyle Nov 21, 2024
6e66c7d
Move examples to multiline YAML strings
kilfoyle Nov 21, 2024
fa1fe32
A couple of corrections
kilfoyle Nov 21, 2024
a31d564
Merge branch 'main' into generate-settings-testing-02
kilfoyle Nov 21, 2024
ebd8444
Update readme; Fix missing example comments
kilfoyle Nov 21, 2024
fd7d0e2
Merge branch 'main' into generate-settings-testing-02
kilfoyle Nov 25, 2024
7a62c58
Add in changes from PR 197421 to fix conflict
kilfoyle Dec 3, 2024
035e459
Merge branch 'main' into generate-settings-testing-02
kilfoyle Dec 3, 2024
72135bc
Merge branch 'main' into generate-settings-testing-02
kilfoyle Dec 12, 2024
3008521
Merge branch 'main' into generate-settings-testing-02
kilfoyle Dec 16, 2024
e70c728
multiline string descriptions; add datatypes; fix readme
kilfoyle Dec 17, 2024
a4cbb70
Merge branch 'main' into generate-settings-testing-02
kilfoyle Dec 17, 2024
519cdf9
Merge branch 'main' into generate-settings-testing-02
kilfoyle Dec 19, 2024
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
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -2512,6 +2512,9 @@ oas_docs/.spectral.yaml @elastic/platform-docs
oas_docs/kibana.info.serverless.yaml @elastic/platform-docs
oas_docs/kibana.info.yaml @elastic/platform-docs

# Documentation settings files
docs/settings-gen @elastic/platform-docs

# Plugin manifests
/src/plugins/**/kibana.jsonc @elastic/kibana-core
/x-pack/plugins/**/kibana.jsonc @elastic/kibana-core
Expand Down
257 changes: 257 additions & 0 deletions docs/settings-gen/parse-settings.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
#!/usr/bin/perl

# This little script finds any .yml files in the /source directory and, for each, generates an asciidoc file of the same name.
# The output asciidoc file is a set of tagged regions, one for each configuration setting in the yaml file.
# The tagged region can then be included in any Asciidoc file by means of an `include` statement.
# Run the script with: perl parse-settings.pl
# There are no parameters


use strict;
use warnings;
use YAML::Tiny;
use File::Find;
use File::Copy;

my $file;
# I'm hardcoding these directories just temporarily for testing
my $sourcedir = './source';
my $asciidocdir = 'source/';
my $count;

find(\&iteratefiles, $sourcedir);
print "\n\nProcessed ".$count. " files.\n";
exit;

sub iteratefiles {
$file = $_;
# ignore any non-yaml files
if (!($file =~ /\.yml$/)) {return;}
print "\nParsed file: ".$file;
my $testslice = parsefile($file);
return;
}

sub parsefile {
# Create an output file based on yaml filename
my $outputfile = my $outputfileorig = $file;
$outputfile =~ s/.yml/.asciidoc/g;
# We'll use this to store the contents of the generated asciidoc file

# Read in the yaml file
my $yaml = YAML::Tiny->read( $file );

# Get a reference to the first document
#my $config = $yaml->[0];

my $collection = $yaml->[0]->{collection};
my $product = $yaml->[0]->{product};

# This variable is used to capture all the content that will become our output asciidoc file
my $asciidocoutput = "\n".'// '."This is a generated file; please don't update it directly.\n".'//'." Instead, the updatable source for these settings can be found in ".$outputfileorig;
$asciidocoutput .= "\n".'// '."Collection: ".$collection;
$asciidocoutput .= "\n".'// '."Product: ".$product."\n\n";

# build the page preamble paragraphs
my $page_description = $yaml->[0]->{page_description};
my $page_description_string = "";
for my $paragraph (@$page_description) {
$page_description_string .= $paragraph."\n\n";
}
# remove the + sign after the last paragraph of the description
if ($page_description_string) {
$page_description_string =~ s/\+$//;
chomp ($page_description_string);
}
if ($page_description_string) {
$asciidocoutput .= $page_description_string;
}




my $groups = $yaml->[0]{groups};
for my $group (@$groups) {

# Grab the group name, description, and other properties
my $group_id = $group->{id};
my $group_name = $group->{group};
my $group_description = $group->{description};
my $group_example = $group->{example};

# Add the group info to the asciidoc file contents
$asciidocoutput .= "\n\n";
if ($group_id) {
$asciidocoutput .= "[float]\n[[".$group_id."]]\n=== ".$group_name."\n\n";
}
else {
$asciidocoutput .= "[float]\n=== ".$group_name."\n\n";
}
# build the group preamble paragraphs
my $group_description_string = "";
for my $paragraph (@$group_description) {
$group_description_string .= $paragraph."\n\n";
}
# remove the + sign after the last paragraph of the description
#if ($group_description_string) {
# $group_description_string =~ s/\+$//;
# chomp ($group_description_string);
#}
if ($group_description_string) {
$asciidocoutput .= $group_description_string;
}
# Add an example if there is one, like this: include::../examples/example-logging-root-level.asciidoc[]
if ($group_example) {
$asciidocoutput .= "\n\n$group_example\n\n";
}

my $settings = $group->{settings};
for my $setting (@$settings) {

# Grab the setting name, description, and other properties
my $setting_name = $setting->{setting};
my $setting_id = $setting->{id};
my $setting_description = $setting->{description};
my $setting_note = $setting->{note};
my $setting_warning = $setting->{warning};
my $setting_important = $setting->{important};
my $setting_tip = $setting->{tip};
my $setting_default = $setting->{default};
my $setting_type = $setting->{type};
my $setting_options = $setting->{options};
my $setting_platforms = $setting->{platforms};
my $setting_example = $setting->{example};
my $setting_state = $setting->{state};
my $deprecation_details = $setting->{deprecation_details};

# skip settings that are flagged as "hidden"
if (($setting_state) && ($setting_state =~ /hidden/i)) {next;}

# Get the setting options and option descriptions and build the string
my $options = $setting->{options};
my $setting_options_string = "";
if ($options) {
for my $option (@$options) {
my $option_name = $option->{option};
# if ($option_name) {print "\nOPTION = ".$option_name;}
if ($option_name) {$setting_options_string .= '* `'.$option_name.'`';}
my $option_description = $option->{description};
# if ($option_description) {print "\nDESCRIPTION = ".$option_description;}
if ($option_description) {$setting_options_string .= ' - '.$option_description;}
$setting_options_string .= "\n";
}
}

# check if supported on Cloud (these settings are marked with a Cloud icon)
my $supported_cloud = 0;
for my $platform (@$setting_platforms) {
if ($platform =~ /cloud/) {$supported_cloud = 1;}
}

# build the description paragraphs
my $setting_description_string = "";
for my $paragraph (@$setting_description) {
$setting_description_string .= $paragraph."\n\n";
}

# Currently, we're just adding the "C" icon when Cloud is supported, but in future we might instead want to provide the supported platforms (cloud, serverless, self-managed) as a list.
#my $setting_platforms_string = "";
#for my $platform (@$setting_platforms) {
# $setting_platforms_string .= '`'.$platform.'`, ';
#}
## remove the comma after the last platform in the list
#if ($setting_platforms_string) {$setting_platforms_string =~ s/, $//;}

# Add the settings info to the asciidoc file contents
$asciidocoutput .= "\n";
if ($setting_id) {
$asciidocoutput .= "\n".'[['.$setting_id.']]'."\n";
}
$asciidocoutput .= '`'.$setting_name.'`';
if ($supported_cloud) {
$asciidocoutput .= ' {ess-icon}';
}
$asciidocoutput .= "::\n+\n====\n";

# Add a standard disclaimer for technical preview settings
if ($setting_state) {
if ($setting_state =~ /technical-preview/i)
{
$asciidocoutput .= "\n\npreview::[]\n\n";
}

# Mark deprecated settings and add guidance (such as when it was deprecated) if there is any
elsif ($setting_state =~ /deprecated/i)
{
$asciidocoutput .= "**Deprecated:** ";
if ($deprecation_details) {
$asciidocoutput .= $deprecation_details."\n\n";
}
}
# known setting_states are 'technical-preview', 'deprecated' and 'hidden'. Anything else is ignored.
else {
print "\nUnknown setting state: ".$setting_state."\n";
}
}

if ($setting_description_string) {
$asciidocoutput .= $setting_description_string;
}

if ($setting_note) {
$asciidocoutput .= "\nNOTE: ".$setting_note."\n";
}
if ($setting_warning) {
$asciidocoutput .= "\nWARNING: ".$setting_warning."\n";
}
if ($setting_important) {
$asciidocoutput .= "\nIMPORTANT: ".$setting_important."\n";
}
if ($setting_tip) {
$asciidocoutput .= "\nTIP: ".$setting_tip."\n";
}

# If any of these are defined (setting options, setting default value, settting type...) add those inside a box.
# We put a " +" at the end of each line to to achieve single spacing inside the box.

if (($setting_options_string) || ($setting_default) || ($setting_type)) {
if ($setting_options_string) {
$asciidocoutput .= "\nOptions:\n\n".$setting_options_string."\n";
}
if ($setting_default) {
$asciidocoutput .= "Default: ".'`'.$setting_default.'`'.' +'."\n";
}
# Removing this. Instead, settings supported on Cloud will be marked with the "C" icon.
# if ($setting_platforms_string) {
# $asciidocoutput .= "+\nPlatforms: ".$setting_platforms_string."\n";
# }
if ($setting_type) {
$asciidocoutput .= 'Type: `'.$setting_type.'` +'."\n";
}
}

# Add an example if there is one, like this: include::../examples/example-logging-root-level.asciidoc[]
if ($setting_example) {
$asciidocoutput .= "\n\n$setting_example\n\n";
}

$asciidocoutput .= "====\n";
}
}


# Just in case we need to grab all of the keys, this is how:
# foreach my $key (keys %hash) { ... }

$asciidocoutput .= "\n\n";

# write the contents into the generated asciidoc file
open (WRITE, "> $outputfile") or die("$!");
print WRITE $asciidocoutput;
close WRITE;
print "\nGenerated file: ".$outputfile;
++$count;

return;
}

97 changes: 97 additions & 0 deletions docs/settings-gen/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# YAML-based settings documentation

We're aiming to update the Kibana configuration settings pages to be based off of YAML-formatted source files. The approach has the advantages that:
- The YAML format makes it easier to add new settings and update existing ones. The setting data is separate from almost all formatting, whether Asciidoc or (future) Markdown.
- The HTML files will have a more consistent and user-friendly appearance.
- The YAML format makes it easier for teams to identify missing settings or settings that are lacking details that should be made available in the docs.

The YAML settings files in the `settings-gen/source` folder are converted to Asciidoc source, located in the same directory, by means of the `parse-settings.pl` Perl script. Please do not update the generated Asciidoc files directly as your changes will be overwritten. Please make any required docs changes in the `<name>-settings.yml` files.

Following is a schema for all available properties in a YAML settings file.



## Schema with descriptions

```
product: <Required (string) - the Elastic product name, e.g. 'Elasticsearch', 'Kibana', 'Enterprise Search', 'Elasticsearch Service', 'Elastic Cloud Enterprise'>
collection: <Required (string) - the settings page title, e.g. Alerting and action settings in Kibana>
page_description:
- <"Optional (asciidoc) - A summary description that appears at the top of the settings page">

groups:
- group: [Optional] (string) - Section title on the settings page, e.g. Preconfigured connector settings
id: [Optional] (string) - ID used for documentation links, e.g., general-alert-action-settings
description:
- [Optional] (asciidoc in quotes) - The description content that appears below the group title.
- [Optional] (asciidoc in quotes) - Paragraph 2
- [Optional] (asciidoc in quotes) - Paragraph 3
example: |
These lines are interpreted as literal strings.
Include any complex Asciidoc such as tables, lists, code examples, etc.
Note that comments marked by # are ignored

settings:
- setting: [Required] (string) - Setting name, e.g. xpack.encryptedSavedObjects.encryptionKey
setting_id: <Optional (string) - ID to used for documentation links, e.g., xpack-encryptedsavedobjects-encryptionkey.>
description:
- [Optional] (asciidoc in quotes) - The description content that appears below the group title.
- [Optional] (asciidoc in quotes) - Paragraph 2
- [Optional] (asciidoc in quotes) - Paragraph 3
state: [Optional] - 'deprecated', 'technical-preview', or 'hidden'
deprecation_details: [Optional] (asciidoc in quotes) - details about when it was deprecated and/or what setting to use instead
note: [Optional] (asciidoc in quotes) - Text to display in a 'note' callout
tip: [Optional] (asciidoc in quotes) - Text to display in a 'tip' callout
warning: [Optional] (asciidoc in quotes) - Text to display in a 'warning' callout
important: [Optional] (asciidoc in quotes) - Text to display in an 'important' callout
default: [Optional] (string) - The setting's default value
options:
- option: [Optional] (string) - A setting option, e.g., zh-cn
description: [Optional] (asciidoc in quotes) - Description of the setting option
- option: [Optional] (string) - A setting option, e.g., ja-jp
description: [Optional] (asciidoc in quotes) - Description of the setting option
type: [Optional] One of 'static' or 'dynamic'
platforms:
- [Optional] - one of cloud/serverless/self-managed
- [Optional] - one of cloud/serverless/self-managed
- [Optional] - one of cloud/serverless/self-managed
example: |
These lines are interpreted as literal strings.
Include any complex Asciidoc such as tables, lists, code examples, etc.
Note that comments marked by # are ignored
```


## Schema without descriptions (for easier cutting and pasting)

```
product: REQUIRED
collection: REQUIRED

groups:
- group: REQUIRED
id: REQUIRED
# description:
# - ""
# example: example-group-name.asciidoc
settings:

- setting: REQUIRED
# id:
description:
- "REQUIRED"
# state: deprecated/hidden/tech-preview
# deprecation_details: ""
# note: ""
# tip: ""
# warning: ""
# important: ""
# default:
# options:
# - option:
# description: ""
# type: static/dynamic
# platforms:
# - cloud/serverless/self-managed
# example: |
```
Loading