-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add unidoc directive for markdowns #24563
Conversation
another cluster. It only needs to know the location of one (or more) nodes to use as initial | ||
contact points. It will establish a connection to a @scala[@scaladoc[`ClusterReceptionist`](akka.cluster.client.ClusterReceptionist)]@java[@javadoc[`ClusterReceptionist`](akka.cluster.client.ClusterReceptionist)] somewhere in | ||
contact points. It will establish a connection to a @unidocRef[ClusterReceptionist](akka.cluster.client.ClusterReceptionist) somewhere in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using @unidocRef
instead of @unidoc
, because @unidoc
gave the following error:
Error writing content for page cluster-client.html: 2 matches found for ClusterReceptionist, but not
javadsl/scaladsl: akka.cluster.client.ClusterReceptionist,
akka.cluster.typed.internal.receptionist.ClusterReceptionist
Matched two classes are not javadsl
/scaladsl
variants.
Although @unidoc
by UnidocDirective
works nicely with a concise syntax, it doesn't work in cases like above. Hence this syntax, @unidocRef[ClusterReceptionist](akka.cluster.client.ClusterReceptionist)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree being able to point to a particular class when unidoc can't figure it out on its own is useful. Could we even do that in one directive, so allowing @unidoc[ClusterReceptionist](akka.cluster.client.ClusterReceptionist)
or perhaps even @unidoc[client.ClusterReceptionist]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think handling both @unidoc[ClassName]
and @unidoc[ClassName](path.to.ClassName)
is difficult, as we need to
- extract if
(path.to.ClassName)
part exists, - and if 1 is not found, fall back to the current logic for
@unidoc[ClassName]
The problem with 1 is that we need the same logic as SourceDirective
's resolvedSource, which is sealed
inside Paradox.
For @unidoc[client.ClusterReceptionist]
, I can give it a try. Hopefully that does not clutter the code to extract the label
and filtering logic here..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@unidoc[client.ClusterReceptionist]
was actually almost already handled. So I only made a slight change.
You can see the generated page here
}.value | ||
) | ||
|
||
class UnidocDirective(allClasses: IndexedSeq[String]) extends InlineDirective("unidoc") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copied from akka/akka-http#1579 removing unnecessary stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What unnecessary stuff could be removed? can we also remove it over there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary stuff was removed in 4161175 - unused parameters, and case 2
in the pattern match could be handled by case n
.
As we are making the new sbt plugin anyway, we don't need to do the same in akka-http? However, if the plugin takes too much time, yes I'll do that in akka-http.
project/ParadoxSupport.scala
Outdated
} | ||
} | ||
|
||
class UnidocRefDirective(page: Page, variables: Map[String, String]) extends InlineDirective("unidocRef") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this comment for the motivation.
Test PASSed. |
This is very nice! As the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! I agree with adding it to akka-paradox.
We should package the directive as a separate sbt plugin. I do not think we have yet seen a paradox directive pacakged separately as an sbt plugin, but it seems to be doable. |
I can work on the sbt plugin later, but is it ok to firstly add the Otherwise, I need to make sure the |
Incubating it in the project and extracting it later seems fine to me |
project/ParadoxSupport.scala
Outdated
}) | ||
case n => | ||
throw new java.lang.IllegalStateException(s"$n matches found for $label, but not javadsl/scaladsl: ${matches.mkString(", ")}") | ||
} | ||
} | ||
} | ||
|
||
class UnidocRefDirective(page: Page, variables: Map[String, String]) extends InlineDirective("unidocRef") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turned out @unidocRef
is not needed as @unidoc[path.to.ClassName]
was already handled.
Think it's good for another round of review. |
Test PASSed. |
@@ -3,7 +3,7 @@ | |||
An actor system that is not part of the cluster can communicate with actors | |||
somewhere in the cluster via this @unidoc[ClusterClient]. The client can of course be part of | |||
another cluster. It only needs to know the location of one (or more) nodes to use as initial | |||
contact points. It will establish a connection to a @unidocRef[ClusterReceptionist](akka.cluster.client.ClusterReceptionist) somewhere in | |||
contact points. It will establish a connection to a @unidoc[client.ClusterReceptionist] somewhere in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit strange though, it's neither the FQCN nor the simple name but something in-between, I think either @unidoc[ClusterReceptionist]
or @unidoc[akka.cluster.client.ClusterReceptionist]
is what we'd want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, added a new commit to only allow FQCN or a simple class name (without any .
).
project/ParadoxSupport.scala
Outdated
printer.print(s"</span>") | ||
} catch { | ||
case e: LinkException => | ||
throw new LinkException(s"${e.getMessage}. You may want to use the fully qualified class name as `@unidoc[fqcn]`.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message is like:
[error] Caused by: com.lightbend.paradox.markdown.ExternalLinkDirective$LinkException: Failed to resolve [client.ClusterReceptionist] referenced from [cluster-client.html] because property [javadoc.base_url] is not defined. You may want to use the fully qualified class name as @unidoc[fqcn].
[error] at akka.ParadoxSupport$UnidocDirective.renderByFqcn(ParadoxSupport.scala:94)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Test PASSed. |
case n => | ||
throw new java.lang.IllegalStateException( | ||
s"$n matches found for @unidoc[$label], but not javadsl/scaladsl: ${matches.mkString(", ")}. " + | ||
s"You may want to use the fully qualified class name as @unidoc[fqcn] instead of @unidoc[${label}]." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message is like:
[error] Caused by: java.lang.IllegalStateException: 2 matches found for @unidoc[ClusterReceptionist], but not javadsl/scaladsl: akka.cluster.client.ClusterReceptionist, akka.cluster.typed.internal.receptionist.ClusterReceptionist. You may want to use the fully qualified class name as @unidoc[fqcn] instead of @unidoc[ClusterReceptionist].
[error] at akka.ParadoxSupport$UnidocDirective.renderByClassName(ParadoxSupport.scala:78)
Test PASSed. |
Test FAILed. |
(Ignore the latest failure, I was testing a Jenkins thing) |
Test FAILed. |
PLS BUILD |
Test PASSed. |
project/ParadoxSupport.scala
Outdated
} | ||
} | ||
|
||
def renderByClassName(label: String, node: DirectiveNode, visitor: Visitor, printer: Printer): Unit = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be neat if this logic would just find the fqcn based on the short text and then re-use renderByFqcn
, would that be possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I iterated further on this a bit in akka/akka-http#1890, could you have a look whether what I did there make sense and if so apply the same here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, copied UnidocDirective
from akka/akka-http#1890
Test PASSed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a bunch!
Closes #24426
Generated page under my firebase project:
https://doc.akka.io/docs/akka/current/cluster-client.html#cluster-client
I want to:
@unidoc
in akka, and make sure it works for all .md files in akka which would take time@unidoc
to either akka-paradox or paradoxis that ok? or should we just do 2?
Copied
UnidocDirective
from akka/akka-http#1579, and addedUnidocRefDirective
to avoid the issue described hereAs the first step, modified cluster-client.md to see how
@unidoc
works.