-
Notifications
You must be signed in to change notification settings - Fork 479
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
Allow arbitrary variables to be passed to be stored in User and Internal #864
Conversation
I've updated the PR to make the same change to the internal struct. This way, extensions to Documenter can use the |
This is in a state where it can be merged. Now the question is if this is the right approach to allowing external components to interact with the internal Documenter pipeline. I'm not particularly tied to this solution, but I do think that something to this effect is needed. |
Apologies for not getting to this earlier and thanks for bringing this up! I do think this will require some bikeshedding. Here are some general comments that may or may not be relevant:
So I think that I would ideally pass a makedocs(
sitename = "...",
HTML(canonical = "..."), # equiv to current html_canonical="..."
Plugin(foo = "bar"),
) Or better yet, maybe a makedocs(
sitename = "...",
HTML(html_canonical = "..."),
CitationsPlugin(foo = "bar"),
SomeOtherPlugin(baz = "qux"),
) I think there is some value in namespacing these things, as you might get name clashes otherwise if you have multiple plugins. We also need some methods acting on the I need to think about this a bit more though and would love to hear opinions on this. |
The struct-per-plugin approach seems much better to me. I knocked together a prototype of that system. A few comments about this prototype:
I also looked at your proposed interface, and I have a few thoughts about that:
|
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 like this! I think we can stick with this general structure. Could just use some docs.
I think that I've updated all of the relevant docstrings, but it is entirely possible that I missed somethings. Also, it looks like there are a lot more things |
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.
Looks good! A few last things to do and it is good to go I think:
- We should switch out
docs/make.jl
over to this. - Also the tests under
test/formats
andtest/example
src/Documenter.jl
Outdated
|
||
|
||
# User Interface. | ||
# --------------- | ||
|
||
export Deps, makedocs, deploydocs, hide | ||
|
||
export Deps, makedocs, deploydocs, hide, 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.
It turns out that HTML
is already being exported by Base
, so one needs to do explicit Documenter.HTML
. But that's a bit long.. so I am wondering if there is a better way.
Maybe export
Writers
and have it be accessible by Writers.HTML
:
makedocs(
Writers.HTML(prettyurls=false),
...
)
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 opted for Documenter.HTML
because pretty soon Writers
will only have a single writer under it. Also, make.jl
files shouldn't be edited too often, so the extra typing seems insignificant.
I can change it if you feel strongly that Writers.HTML
is the right way forward.
I just squashed this into two logical commits. I see you added a news label, but I'm not sure where the news should go? Is there anything else that needs to be done here? |
I would like to take another proper look at this and I should be able to get to it on the weekend. But I think it is most likely good to go, except for the conflict in |
Add depreciations, update docstrings, fix tests, and export Documenter.HTML
type is still a reserved keyword on 0.7...
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.
Looks great! Thanks for iterating on this!
""" | ||
function getplugin(doc::Document, plugin_type::Type{T}) where T <: Plugin | ||
if !haskey(doc.plugins, plugin_type) | ||
doc.plugins[plugin_type] = plugin_type() |
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.
Wouldn't it be better to return nothing
here instead of assuming that T
has a T()
constructor?
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 rational was to make the interface as easy as possible from the user's perspective. With this implementation, a user can just using SomePlugin
in make.jl
and things will Just Work (tm).
Do you have an example implementation that make use of this @adamslc ? |
The `HTMLWriter now uses a plugin, and I have a prototype of a Citation package that uses this feature here. |
This PR is the start of an attempt to make
Documenter
support passing arbitrary arguments frommakedocs
through to aWriter
. So far, I have just removed a few of the HTML specific variables fromUser
, but, if people this that this is a reasonable approach, I will continue to strip away the special case variables.One downside to this approach as it is currently implemented is that it scatters the default values for variables throughout the code. But this could be resolved with a few
get!
s at the start of therender
function in each writer.Another potential downside is the performance hit resulting from the untyped dictionary. I haven't done any benchmarking to see if this is significant.