-
Notifications
You must be signed in to change notification settings - Fork 84
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
Default value expressions are returned incorrectly #240
Comments
I encountered this with a default expression like |
I have also encountered this bug. |
There seems to be [a bug in puppet strings][] that prevents default values from being outputted correctly in REFERENCE.md. Values of the form `$var.func(...)` would output as `(...)`. This switches over to the `func($var, ...)` form, though unfortunately I think it is less readable. [a bug in puppet strings]: puppetlabs/puppet-strings#240
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Well, You can try my branch: main...danielparks:puppet-strings:fix_default_expressions (That includes a fix for the ERB warnings as well, though it will break on Ruby <2.6, I think, so it can’t be committed. See #302) |
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Filed ticket https://tickets.puppetlabs.com/browse/PUP-11632 (not sure that’s the right project, but ¯\_(ツ)_/¯) |
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad).
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad). Unfortunately, it appears that there is a bug in Puppet ([PUP-11632][]) that sometimes returns the incorrect default value. This adds two skipped tests that demonstrate the issue. [PUP-11632]: https://tickets.puppetlabs.com/browse/PUP-11632
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad). Unfortunately, it appears that there is a bug in Puppet ([PUP-11632][]) that sometimes returns the incorrect default value. This adds two skipped tests that demonstrate the issue. [PUP-11632]: https://tickets.puppetlabs.com/browse/PUP-11632
Due to a [bug in Puppet Strings][bug], the default values were being outputted in REFERENCE.md incorrectly. Commit c3db65b fixed the problem at the cost of making the default values harder to understand. I have fixed the bug in Puppet Strings (though it hasn’t been merged and released), so this reverts the aforementioned commit and generates a fresh REFERENCE.md. [bug]: puppetlabs/puppet-strings#240
Due to a [bug in Puppet Strings][bug], the default values were being outputted in REFERENCE.md incorrectly. Commit c3db65b fixed the problem at the cost of making the default values harder to understand. I have fixed the bug in Puppet Strings (though it hasn’t been merged and released), so this reverts the aforementioned commit and generates a fresh REFERENCE.md. [bug]: puppetlabs/puppet-strings#240
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad). Unfortunately, it appears that there is a bug in Puppet ([PUP-11632][]) that sometimes returns the incorrect default value. This adds two skipped tests that demonstrate the issue. [PUP-11632]: https://tickets.puppetlabs.com/browse/PUP-11632
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad). Unfortunately, it appears that there is a bug in Puppet ([PUP-11632][]) that sometimes returns the incorrect default value. This adds two skipped tests that demonstrate the issue. [PUP-11632]: https://tickets.puppetlabs.com/browse/PUP-11632
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad). Unfortunately, it appears that there is a bug in Puppet ([PUP-11632][]) that sometimes returns the incorrect default value. This adds two skipped tests that demonstrate the issue. [PUP-11632]: https://tickets.puppetlabs.com/browse/PUP-11632
(#240) Fix output of default values that are expressions
Previously, parameters with a default value that was an expression were not outputted into the documentation correctly. For example, Integer $param = 1 + 1, Would be shown in the documentation to have a default value of “+”. This switches to using `extract_tree_text` instead of `extract_text` to get the text representation of the parsed Puppet code. This also gets rid of the dependency on `Puppet::Pops::Adapters::SourcePosAdapter`, which was [deprecated in 2017](puppetlabs/puppet@68498ad). Unfortunately, it appears that there is a bug in Puppet ([PUP-11632][]) that sometimes returns the incorrect default value. This adds two skipped tests that demonstrate the issue. [PUP-11632]: https://tickets.puppetlabs.com/browse/PUP-11632
Partially fixed — it’s much better, but sometimes PUP-11632 strips the final character. |
Describe the Bug
Complex parameter default expressions (specifically those involving an AST branch node) are returned incorrectly.
For example:
The default value for
$param
is returned as+
.Expected Behavior
The default value should be returned as
1 + 1
.Additional Context
This seems to happen because
ParameterizedStatement
parser uses aSourcePosAdapter
from Puppet to extract the text for the AST object. However, theextract_text
method it calls only extracts the text for the AST branch itself, not for the entire tree rooted in that branch. TheSourcePosAdapter
calls@object.locator.extract_text
, but there is anextract_tree_text
method available on the locator which seems to do the right thing.https://github.com/puppetlabs/puppet-strings/blob/main/lib/puppet-strings/yard/parsers/puppet/statement.rb#L89-L90
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/pops/adapters.rb#L63
https://github.com/puppetlabs/puppet/blob/master/lib/puppet/pops/parser/locator.rb#L55
I would file a PR but I'm not deep enough into puppet-strings to understand its relationship to Puppet and the compatibility issues involved with the
SourcePosAdapter
to know the appropriate place to make this change.The text was updated successfully, but these errors were encountered: