-
Notifications
You must be signed in to change notification settings - Fork 496
Allow specifying a global default for @meta
block settings
#2697
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
base: master
Are you sure you want to change the base?
Conversation
94d1dd7
to
3dad9c5
Compare
I am happy with this now. Any thought, @lgoettgens @mortenpi ? |
src/makedocs.jl
Outdated
@@ -166,6 +166,8 @@ For example, if you have `foo.md` and `bar.md`, `bar.md` would normally be evalu | |||
Evaluation order among the `expandfirst` pages is according to the order they appear in the | |||
argument. | |||
|
|||
**`default_meta`** can be set to TODO. TODO default `@meta` block. TODO |
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.
Just bikeshedding this here. I was thinking maybe it could be page_meta
or even just meta
.
So, currently, this will only affect the Markdown pages, and for docstrings you'd still have to do setdocmeta!
, right? I am now wondering if this should also apply to docstrings (with setdocmeta!
providing a per-module override still).
Do you have any sense if the global at-meta stuff you'd like to apply for pages would also be useful for docstrings? Are they usually basically the same in your experience?
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.
We use the same DocTestSetup
in @meta
blocks in every .md
file and also set it via setdocmeta!
. I believe they would be basically the same, and having default_meta
/page_meta
/meta
also set a default for doctests
inside docstrings would then unify 2 of 3 places where in my experience one needs to set these
So it'd help! But maybe not quite enough, at least if one also wants to run doctests outside of building the documentation. We do that (via an explicit doctest(MyPackage)
call in our CI) in order to get code coverage.
For details see also my comment #2126 (comment)
I'm happy if it's a |
test/default_meta/tests.jl
Outdated
|
||
makedocs( | ||
sitename = "Test", pages = pages, doctest = true, | ||
default_meta = Dict(:DocTestSetup => :(x = 42)) |
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.
Just to say, one could also allow (instead or in addition) named tuples:
default_meta = Dict(:DocTestSetup => :(x = 42)) | |
default_meta = (DocTestSetup = :(x = 42), ) |
OK that's a bit awkward in the single argument list. But it is a tad closer to how the content of the @meta
blocks look (no :
in front of names, =
instead of =>
)
Anyway I am totally fine either way, just wanted to bring it up
This allows to e.g. use a common doctest setup block on all pages, thus complementing `DocMeta.setdocmeta!`. Other nice applications include changing certain settings, such `CollapsedDocStrings = true` globally, or being able to specify `CurrentModule = YourPackageModule` globally.
3dad9c5
to
c82cbb1
Compare
I've resolved the TODOs and renamed |
This allows to e.g. use a common doctest setup block on all pages, thus complementing
DocMeta.setdocmeta!
.Other nice applications include changing certain settings, such
CollapsedDocStrings = true
globally, or being able to specifyCurrentModule = YourPackageModule
globally.Resolves #2512. Resolves #2684. Resolves #1253
CC @lgoettgens
This is a first prototype. No documentation or changelog entry yet as the design is still not finalized.
This adds a new kwarg
default_meta
tomakedocs
-- contrary to the discussion in #2512 this expects aDict{Symbol,Any}
. The main reasons for doing it this way are:I've been wondering if it wouldn't be nicer to accept a named tuple instead of (or in addition to?) a
Dict{Symbol,Any}
, the syntax then would look a bit closer to the actual content of a@meta
block.Of course accepting actual quoted code blocks would make the input even closer to an actual
@meta
block. As I wrote above, we could still add support for that if it turns out someone needs it. When we do, it then should also be easier to resolve the question "when to evaluate the code block" (once at the start? once for each page? something else?) because we'll have a concrete usecase at hand...That said, I am totally open to change this MVP based on your comments.