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

Fix #3791 Add adverbs to --doc compiler module definition #3807

Closed
wants to merge 3 commits into from
Closed

Fix #3791 Add adverbs to --doc compiler module definition #3807

wants to merge 3 commits into from

Conversation

finanalyst
Copy link
Contributor

When compiler called with --doc=XXXX only the module Pod::To::XXX is loaded.
--doc=XXXX:ver<1.2.3>:auth<Perl 6> will cause an error.

This patch recognises :ver<>:auth<>:api<> combinations. In addition, it allows for --doc=Some::Arbitrary::Renderer to be
checked. If no such module exists, then Pod::To::Some::Arbitrary::Renderer is attempted to be loaded.

When compiler called with --doc=XXXX only the module Pod::To::XXX is loaded.
--doc=XXXX:ver<1.2.3>:auth<Perl 6> will cause an error.

This patch recognises :ver<>:auth<>:api<> combinations. In addition, it allows for --doc=Some::Arbitrary::Renderer to be
checked. If no such module exists, then Pod::To::Some::Arbitrary::Renderer is attempted to be loaded.
@ugexe
Copy link
Member

ugexe commented Jul 19, 2020

fwiw I’ve never liked arbitrary namespace prefixes in raku, especially in combination with full namespaces. Things like what to load when passed ‘Foo’ and both Pod::To::Foo and Foo exists (picking one or the other is easy, but makes things inconsistent for the sake of saving a few keystrokes).

Copy link
Collaborator

@JJ JJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a nice attempt, but it needs to improve. Also, it would need a test.

my $rx := /
^
$<name> = ( [ \w | '::' ] + )
[ ':' $<part> = ( [ 'ver' | 'auth' | 'api' ] )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would match "::a::::bbbbb". I think rakudo has a canonical parser for this, can you please look this up?
Also :ver<0.1>:ver<33>. You might end up with something you can't instantiate and fail later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a) Don;t think so because : must be followed by ver/auth/api. : (::bbbbb) and :: (:bbbbb) would fail.
b) I am certain it does, but where? and how could I look this up? nqp documentation is not so good. I have looked at everything on nqp site.

while $i < $e { nqp::bindkey( %opts, ~ @parts[$i], ~ @vals[$i++] ) };

my $renderer := ~ nqp::atkey($s,'name');
my $module;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You sure that what atkey remembers is something other than a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. atkey returned matches for the parts and vals. That caused failures, so the ~ was needed there. I added for name, just incase.

$module := $*W.load_module($/, $renderer, %opts, $block);
CATCH {
$renderer := 'Pod::To::' ~ nqp::atkey($s,'name');
$module := $*W.load_module($/, $renderer, %opts, $block);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this fails? Also, you're introducing the ambiguity that @ugexe has pointed out, which means that now Any::Renderer::I::Want could be used here. Do we want this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JJ I think you misunderstood @ugexe, or perhaps I do.
He was saying, like I was saying, the argument to --doc= should be a fully qualified module.
But the API requires (as Damian Conway stated in his original POD specification) that it should be --doc=HTML.

@AlexDaniel pointed out that =HTML already exists and is documented.

So my suggestion is to test for the fully qualified name, but then test for a Pod::To::xxx name.

If that also fails, then the compiler fails, as it does now. There is no default specified. It could default to Pod::To::Text but that is NOT yet specified anywhere.

@niner
Copy link
Collaborator

niner commented Sep 5, 2020

I think treating the module name as fully qualified and falling back on trying with a Pod::To:: prefix to stay compatible with documented behaviour is a good strategy. The alternative would be to treat some names as special.
Regarding the implementation, the CATCH block would really need to check the actual exception. You only want to try the prefix if no module was found, not e.g. if the module was loaded but threw an exception from its mainline. Swallowing all exceptions indiscriminately is never a good idea.

@lizmat
Copy link
Contributor

lizmat commented Oct 4, 2020

@finanalyst should this PR still remain open?

@lizmat
Copy link
Contributor

lizmat commented Jan 5, 2022

I'm unsure as to the state of this PR. Does this need more work? Can it be merged? Should it be closed?

@JJ
Copy link
Collaborator

JJ commented Jan 6, 2022

I would need to check it a bit more extensively. Probably some Rakudo tests would need to be written too, since it's introducing new behavior.

@coke coke changed the base branch from master to main April 19, 2023 15:34
@finanalyst finanalyst closed this by deleting the head repository May 4, 2023
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

Successfully merging this pull request may close these issues.

5 participants