I'm trying to override the `<head>` of the HTML format. I see I can do: ```dokka { pluginsConfigur...
c
I'm trying to override the
<head>
of the HTML format. I see I can do:
Copy code
dokka {
	pluginsConfiguration.html {
		templatesDir.set(file("docs/dokka/overrides"))
	}
}
However that seems to only apply to the "All modules" page. Is it possible to make it apply to all pages?
o
Hm, yes. You need to apply this configuration to all projects where Dokka is configured, as Dokka will first generate "partial" HTMLs for each project and only then aggregate them into a multi-module HTML output.
c
That's very inconvenient. I can't add this line to a convention plugin because it wouldn't have access to the file (the convention plugins are in another repo) and it must be file so I can't just bundle it in the convention plugins. So what I have to do: • Bundle the file in the convention plugin • Create a task that reads from the plugin resources and creates the templates directory • Configure Dokka to that directory Is that right? That also means I won't be able to update that value without republishing the configuration plugins etc.
o
Yeah, if the convention plugins are in a separate repo, it might be inconvenient, and what you are suggesting is an option. I see multiple solutions/ideas here, based on the fact that you have those convention plugins in a separate repository for a reason. 1. If you want all your other projects to have the same configuration and templates, then yes, the best way to go is to bundle those templates. In this case, I don't really see why in that case, you might want to update the templates separately per project (feel free to add more context here) 2. If you want your projects to have different templates, but the same configuration, I do have two options: a. You can define some explicit directory, like
rootProjectDir.resolve("dokka-templates")
- and so put templates there on the final project side (plus optionally, have a fallback to option 1 if needed) b. You can create an additional convention plugin on the final project side, configure templates there, and apply it instead of your convention plugin from the other repo. It's also possible to have a fallback, or even some additional Gradle extension, which will allow you to configure your convention plugin from the other repo. I understand that none of those solutions are ideal, but the use case is far from typical. The current Dokka architecture forces us to apply these configurations to both sub-projects and the aggregation project, and the Gradle architecture doesn't easily allow us to share configurations from the root project to sub-projects (keeping in mind that we also need to share data from sub-projects to the root project, too, e.g., outputs) There are solutions for this, yes, but as far as I recall, we discussed this internally during the DGPv2 design and decided that sharing such configurations should be done via convention plugins within a project, rather than through some magic inside Dokka. CC @Adam Semenenko, maybe he also has some ideas here that don't involve Dokka's re-architecture šŸ™‚ Here is one of the issues related to this "configuration split." In the future, KT-80323 Implement KDoc machine-readable representation, which should help with these kinds of problems
a
maybe he also has some ideas here that don't involve Dokka's re-architecture
If I could re-implement DGP I would stop generating the modules in the individual subprojects. Instead DGP would ship the raw materials (locations of source files, classpaths, etc) to the aggregating project and then the configuration can be applied once and consistently. DGP would lose the 'locality' of module-specific configuration, but it would be easier to solve problems like this. We can probably do this as part of KDoc machine-readable representation. Each subproject would expose the analysed data, and the aggregated project could focus on the front-end configuration.
āž• 1
c
1. If you want all your other projects to have the same configuration and templates, then yes, the best way to go is to bundle those templates. In this case, I don't really see why in that case, you might want to update the templates separately per project (feel free to add more context here)
I do want all of them to have the same configuration (at least, to my current knowledge). However, that configuration might change over time, and I have a three-tier configuration (convention plugin in a repo → the baseline repo → each project repo) so having it in the configuration plugin makes changes very slow. For this specific example, maybe I can live with it.
šŸ‘ 1
DGP would lose the 'locality' of module-specific configuration, but it would be easier to solve problems like this.
Intuitively, I would expect that module-specific configuration affects the contents (e.g. hide private members) and aggregation-wide configuration affects the rendering (e.g. the logo, the page title, etc)
agree 1
o
Yes, I agree, and this is one of the reasons behind KDoc's machine-readable representation: it provides better separation between the "analysis" and "rendering" parts. It should also help with other endeavors, such as MkDocs (Zensical?), docusaurus, or other integrations. Stay tuned for future updates in this regard šŸ™‚
šŸ‘ 1