-
Notifications
You must be signed in to change notification settings - Fork 409
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 the link to homepage to the header if homepageLink is provided #3235
Conversation
fun parseGithubInfo(link: String): Pair<String, String>? { | ||
val ( | ||
_, // entire match | ||
_, // optional 's' in http |
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 do you think about https?://github\\.com/([\\w,\\-_]+)/([\\w,\\-_]+)/.*
where s
is no capturing group?
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.
yeah, agree, that should work, will fix it, thx!
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.
For some reason, I don't see the icon in the header :( temporary preview link from GH actions
private fun calculateSourceUrlFromSourceLinks(): String? { | ||
val githubLinkRegex = Regex("http(s)?://github\\.com/([\\w,\\-_]+)/([\\w,\\-_]+)/.*") |
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.
Optional as it's not that important atm: it looks like this function will be called for each page, so it could be optimized slightly:
- Afaik, each instance of
Regex
will compile the pattern under the hood, which takes some time, and it's generally advised to reuse it if it makes sense and is possible. I think in our case the Regex can be extracted into a companion or a top-level val or something, to be reused. - We only need to calculate the return value once for the whole
DokkaConfiguration
(it will not change in-between invocations), and then we can reuse it. But I can't think of where to save this result off the top of my head. Maybe as a lateinit or a lazy property somewhere? Any ideas? :)
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.
If sourceUrl
does not depend on a page, you can use buildSharedModel
.
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.
Thx!
- extracted
Regex
to companion - moved calculation of link to
buildSharedModel
override val context = MockContext( | ||
override val context by lazy { context(configuration) } | ||
|
||
fun context(testConfiguration: DokkaConfiguration): MockContext = MockContext( |
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.
(if you stick to HtmlRenderingOnlyTestBase
and it's not reverted)
Was there some sort of a problem with it and this refactoring helped?
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.
The problem is, while overall all of extensions are the same for all tests in file, configuration should be different per different tests - otherwise it's not possible to change some specific variables here.
F.e. in this case, I need to test output based on configuration.sourceSets[i].sourceLinks
, and so configuration
is different in each test function
Most likely this is because kotlinx.coroutines has no configuration of sourceLinks for root |
* no GitHub support by default * use URL from base plugin configuration * add integration test for the multi-module project that the homepage link exists everywhere
After internal discussion with @IgnatBeresnev some changes were applied:
Question: Do we need to keep backward compatibility for |
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.
👍👍
Yep, we'll ask someone from the Kotlin Website team to help us with the icon and the styles, I've created a separate issue for that: #3300 |
@@ -73,6 +73,21 @@ class MultiModule0IntegrationTest : AbstractGradleIntegrationTest() { | |||
"Expected moduleC being mentioned in -modules.html" | |||
) | |||
|
|||
val indexHtmls = outputDir.walkTopDown().filter { | |||
it.isFile && it.name == "index.html" |
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 all html files except navigation
might be checked.
@@ -21,6 +21,9 @@ | |||
<@source_set_selector.display/> | |||
</div> | |||
<div class="navigation-controls"> | |||
<#if homepageLink?has_content> | |||
<div class="navigation-controls--btn navigation-controls--homepage" id="homepage-link" role="button"><a href="${homepageLink}"></a></div> |
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 have not checked but it seems to be <a href="${homepageLink}"> <div class="navigation-controls--btn navigation-controls--homepage" id="homepage-link" role="button"/></a>
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.
Im not an html-expert, but at least my variant works. If to switch tags, it doesn't work at my side (may be need to adapt more code)
I think it could be rechecked in scope of #3300
Fixes #2948
Added
homepageLink
parameter toDokkaBase
plugin configuration. When setting it, icon with link tohomepage
will be shown near the theme switcher and search buttons in the header. Default icon is just platform-independent