You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It'd be nice if one could do something the following at the REPL:
julia>begin""" f(x) add `1` to `x` ```jldoctest julia> f(1) 2 ```"""f(x) = x +1end
f
julia>doctest(f)
┌ Info: Testing the documentation for f: total 1 test
└ Test passed!
true
This way, one can use the doctest functionality without having to do all the other things documenter seems to require like having the function in a package, making doc directories, etc.
The text was updated successfully, but these errors were encountered:
Good idea. It shouldn't be very hard to add methods that accept Function and DataType to doctest. Just need to construct the Binding and look up the docstring associated with the function/type. Implementation is up for grabs though.
""" doctest(f::Function; set_meta::Bool = false)Run all doctests for the given function `f`."""functiondoctest(f::Function; set_meta::Bool=false, doctest =true)
S =Symbol(f)
doc, doctest =get_document(set_meta; doctest=doctest)
withenv("COLUMNS"=>80, "LINES"=>24) dowith_unicode(false) do#essentially inspired by Documenter/src/DocTests.jl
pm =parentmodule(f)
bm = Base.Docs.meta(pm)
md = bm[Base.Docs.Binding(pm, S)]
for s in md.order
doctest(md.docs[s], Oscar, doc)
endendendend
Perhaps something like that would be suitable for addition to Documenter?
Actually we also have this super helpful helper:
"""
doctest_fix(f::Function; set_meta::Bool = false)
Fixes all doctests for the given function `f`.
# Examples
The following call fixes all doctests for the function `symmetric_group`:
```julia
julia> Oscar.doctest_fix(symmetric_group)
```
"""
doctest_fix(f::Function; set_meta::Bool = false) = doctest(f; set_meta = set_meta, doctest = :fix)
(And then a bunch more which take a string indicating path and test/fix all files under that path)
Uh oh!
There was an error while loading. Please reload this page.
It'd be nice if one could do something the following at the REPL:
This way, one can use the doctest functionality without having to do all the other things documenter seems to require like having the function in a package, making doc directories, etc.
The text was updated successfully, but these errors were encountered: