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

Application of :error and other configurations globally #56

Closed
finanalyst opened this issue Nov 21, 2024 · 7 comments
Closed

Application of :error and other configurations globally #56

finanalyst opened this issue Nov 21, 2024 · 7 comments

Comments

@finanalyst
Copy link
Contributor

@thoughtstream In #52 we discussed adding the option :error / :!error to custom blocks.
More generally, the specification indicate that how and when errors are generated is left to the renderer.
We have not specified how to affect this within the document.
One of the ideas I included in Raku::Pod::Render is that when a meta option is included in the =begin rakudoc block, then it is treated document meta data and provided to all blocks as a default.
A =config statement is directed to a named Block. I do not want to suggest that the block name can be replaced by a regex. I think that would be too powerful at present.
Suppose an author wants to turn off all error statements, then perhaps we could allow

=begin rakudoc :!error :alt<contact document author>

These would be the default for all blocks, and over-ridden if given by a config or the block option.

@thoughtstream
Copy link

I am extremely wary of allowing any metaoption on an outer block to affect other blocks
(even just those that are nested inside the outer block).

I also worry that we're multiplying entities without necessity, since we already have a mechanism
(i.e. =config) for lexically preconfiguring blocks.

The problem, as you point out, is that this mechanism currently doesn't allow generic configuration
of all block types, only specific configuration of a single block type. And, as you say, the obvious
extension would be to allow the target block type to be specified via a regex, in which case we could
simply configure every block with:

=config  /.*/  :!error :alt<contact document author>

Allowing regexes as =config targets would have many other advantages too.
For example, we could then configure multiple nested list item levels to all use the same bullet:

=config  /^item<[1..4]>/  :bullet« \c[CIRCLED BULLET] »

Or configure all four "literal" formatting codes to allow nested Basis codes:

=config  /C|V|K|T/  :allow<B>

But I agree that supporting regexes as =config targets might require too much effort at the moment,
and that the idea may be better left to RakuDoc v3.

However, I don't see why we couldn't at least support a single "universal target" for =config;
specifically, by allowing the target name to be a Whatever. So your universal :alt tag example
could be written:

=config  *  :!error :alt<contact document author>

@finanalyst
Copy link
Contributor Author

@thoughtstream A single '*' would be consistent with other RakuDoc elements.

  • I'll add a PR in due course for the Spec if its easy to implement (which I think it should be)
  • I'll add the regex idea to the V3 list

@finanalyst
Copy link
Contributor Author

@thoughtstream @lizmat

=config * :!error :alt<contact document author>
Unfortunately a '*' in this position causes a compile error.

 raku -e '"=begin rakudoc\n=config * :one :two\n=end rakudoc".AST.say'
===SORRY!=== Error while compiling /home/richard/development/rakuast-rakudoc-render/EVAL_0
Preceding context expects a term, but found infix = instead.

May be the pseudo block 'any'?

@lizmat
Copy link

lizmat commented Nov 23, 2024

rakudo/rakudo@3f0f974e4b allows * as identifier in =config

@finanalyst
Copy link
Contributor Author

@lizmat you are a genius !

@thoughtstream
Copy link

@lizmat you are a genius !

Indeed! Outstanding work (as usual :-)

@finanalyst
Copy link
Contributor Author

closing as resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants