Skip to content

Commit

Permalink
Documentation updates to correct wrong instructions for HOCON config …
Browse files Browse the repository at this point in the history
…parsing (#5975)
  • Loading branch information
klustria authored Jan 27, 2023
1 parent 3e5fbfd commit 80abd33
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022 Oracle and/or its affiliates.
* Copyright (c) 2017, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -60,6 +60,9 @@ public HoconConfigParserBuilder disableResolving() {

/**
* Enables/disables HOCON resolving substitutions support. Default is {@code false}.
* <p>
* Note: Even if you disable substitution at HOCON parsing time, values can still be resolved at a later time by the
* Helidon Config system.
*
* @param enabled use to enable or disable substitution
* @return modified builder instance
Expand Down
10 changes: 5 additions & 5 deletions docs/se/config/advanced-configuration.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2018, 2022 Oracle and/or its affiliates.
Copyright (c) 2018, 2023 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,7 @@ include::{rootdir}/includes/se.adoc[]
- <<Advanced Config Sources, Advanced Config Sources>>
- <<Advanced Config Parsers, Advanced Config Parsers>>
- <<Config Keys with . in name, Config Keys with . in name>>
- <<filters-and-overrides, Filter Overrides and Token Substitution,>>
- <<filters-and-overrides, Filters, Overrides and Token Substitution>>
- <<Executors for Asynchronous Config Activity, Executors for Asynchronous Config Activity>>
== Overview
Expand Down Expand Up @@ -461,8 +461,8 @@ Config config = Config.create(
ConfigSources.classpath("application.yaml")
.parserMapping( // <1>
key -> "app".equals(key.toString()) // <2>
? HoconConfigParserBuilder.buildDefault()
: null));
? Optional.of(HoconConfigParser.create())
: Optional.empty()));
----
<1> Uses the `parserMapping` method to map keys to parser instances.
Expand Down Expand Up @@ -532,7 +532,7 @@ that might be in the node's name, in this example in `oracle.com`.
<6> The config node `"oracle.com"` has type `OBJECT`...
<7> ...and name `"oracle.com"`.
== Filter, Overrides, and Token Substitution [[filters-and-overrides]]
== Filters, Overrides, and Token Substitution [[filters-and-overrides]]
When your application retrieves a config value, the config system can transform it
before returning the value, according to _filters_, _overrides_, and
_tokens_. The config system provides some built-in instances of these
Expand Down
24 changes: 12 additions & 12 deletions docs/se/config/supported-formats.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2018, 2022 Oracle and/or its affiliates.
Copyright (c) 2018, 2023 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -26,9 +26,9 @@ include::{rootdir}/includes/se.adoc[]
== Contents
- <<Overview>>
- <<Additional Config Formats and Parsers>>
- <<Additional Config Source Types>>
- <<Overview, Overview>>
- <<Additional Config Formats and Parsers, Additional Config Formats and Parsers>>
- <<Additional Config Source Types, Additional Config Source Types>>
== Overview
Helidon Config provides several extension modules that support other configuration
Expand Down Expand Up @@ -172,14 +172,14 @@ The same module and parser supports file type `.json` and the media type
.HOCON parser specified - no file type on source
----
Config config = Config.create(classpath("my-config") // <1>
.parser(HoconConfigParserBuilder.buildDefault())); // <2>
.parser(HoconConfigParser.create())); // <2>
----
<1> the media type of the source `my-config`is unknown, so the config system cannot
<1> the media type of the source `my-config` is unknown, so the config system cannot
choose a parser automatically.
<2> The config system will parse the resource `my-config` using the HOCON parser created
by the link:{config-javadoc-base-url}/io/helidon/config/hocon/HoconConfigParserBuilder.html[HoconConfigParserBuilder].
The `buildDefault()` method creates a config parser with default behavior.
by the link:{config-javadoc-base-url}.hocon/io/helidon/config/hocon/HoconConfigParser.html[HoconConfigParser].
The `create()` method creates a config parser with default behavior.
[source,java]
.Media type specified
Expand All @@ -199,7 +199,7 @@ type.
----
Config config = Config.builder(classpath("application.conf"))
.disableParserServices() // <1>
.addParser(HoconConfigParserBuilder.buildDefault()) // <2>
.addParser(HoconConfigParser.create()) // <2>
.build();
----
Expand All @@ -211,8 +211,8 @@ Config config = Config.builder(classpath("application.conf"))
----
Config config = Config.builder(classpath("application.conf"))
.disableParserServices()
.addParser(HoconConfigParserBuilder.create() // <1>
.disableResolving() // <2>
.addParser(HoconConfigParser.builder() // <1>
.resolvingEnabled(false) // <2>
.build()) // <3>
.build();
----
Expand All @@ -224,7 +224,7 @@ Config config = Config.builder(classpath("application.conf"))
You can also specify
link:https://github.com/lightbend/config/blob/master/config/src/main/java/com/typesafe/config/ConfigResolveOptions.java[`ConfigResolveOptions`]
using the `HoconConfigParserBuilder.resolveOptions` method.
using the `HoconConfigParser.builder().resolveOptions` method.
== Additional Config Source Types
Expand Down

0 comments on commit 80abd33

Please sign in to comment.