Repository navigation
Conversation
95684f5 to
7f81363
Compare
|
Need to update the documentation: https://github.com/apache/buildstream/blob/master/doc/source/format_intro.rst#-list-prepend |
7f81363 to
fdff60d
Compare
I gave it a go, please see what it looks like. Don't be afraid of saying it's a bit shit, it's always harder to document something more abstract. Ideas welcome. |
83661df to
b23345e
Compare
|
I think all the concerns have been addressed now. |
b23345e to
dc75e2a
Compare
When composing onto a string allow prepending and appending onto them. It uses the same operators we use for lists (<), (=) and (>).
dc75e2a to
40bc464
Compare
They are for strings too now!
40bc464 to
9159523
Compare
| target.value.clear() | ||
| target.value.extend(clobber.value) |
There was a problem hiding this comment.
This doesn't look right for strings. I'd expect a simple assignment to work fine, though.
| target.value.clear() | |
| target.value.extend(clobber.value) | |
| target.value = clobber.value |
| if type(target_value) is SequenceNode: | ||
| # Composite list composes into a list | ||
| self._compose_on_list(target_value) | ||
| elif isinstance((<ScalarNode> target_value).value, str): |
There was a problem hiding this comment.
Doesn't this require a type check before the cast to ScalarNode?
| self._compose_on_string(target_value) | ||
| elif target_value._is_composite_list(): | ||
| # Composite list merges into composite list | ||
| self._compose_on_composite_dict(target_value) |
There was a problem hiding this comment.
_compose_on_composite_dict only knows about list, not string composition. Couldn't this be hit via multiple includes? It may be acceptable to start with this as known limitation, if there is a reasonable error.
| # Compose the current node on the given string. | ||
| # | ||
| # Args: | ||
| # target (.SequenceNode): sequence on which to compose the current composite dict |
| .. _format_directives_list_append: | ||
|
|
||
| (>) List Append | ||
| For strings: |
There was a problem hiding this comment.
This is an example for prepend, so it should be above the _format_directives_list_append marker (and I think the _format_directives_string_append marker is unused.
| if prefix is not None: | ||
| target.value = prefix.value + target.value | ||
| if suffix is not None: | ||
| target.value += suffix.value |
There was a problem hiding this comment.
As ScalarNode strips whitespace from the start and end of strings (even if they're quoted), it won't be possible to append e.g. " -foo" to a flags variable, as far as I can tell. Not sure what the best solution is for this, especially considering backwards compatibility, but this might block real use cases.
When composing onto a string allow prepending and appending onto them.
It uses the same operators we use for lists (<), (=) and (>).