Skip to content

Conversation

dourouc05
Copy link
Contributor

I wished I had this when I started with CP stuff, so here it is :). It's mostly agnostic to #1474, only two sentences would need to be changed.

What is the preferred way of exploring the terms of a function? For now, I've been mostly using the terms member; should it be advertised more as a recommended practice?

Copy link
Member

@odow odow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! One major comment: should we consider formatting this as a literate tutorial so we make sure it runs? The alternative is to have everything as doctests.

Currently people can't copy-paste the code and have it run.

@dourouc05
Copy link
Contributor Author

I have no idea how to make a literate tutorial or doctests, that's the main reason why I started in this way. I saw inhttps://github.com/jump-dev/MathOptInterface.jl/blob/master/docs/src/tutorials/example.md that there are a lot of jldoctest: I guess this is related to https://juliadocs.github.io/Documenter.jl/stable/man/doctests/#REPL-Examples?

@odow
Copy link
Member

odow commented Aug 24, 2021

that there are a lot of jldoctest

Yeah. These blocks get run on build to check that they reproduce the output. That way you can make sure you don't have typos in the documentation.

The alternative is Literate.jl (https://github.com/fredrikekre/Literate.jl)

Here's one from JuMP:

https://github.com/jump-dev/JuMP.jl/blob/master/docs/src/tutorials/Getting%20started/an_introduction_to_julia.jl

Here's the modification to make to the docs/make.jl

https://github.com/jump-dev/JuMP.jl/blob/5a739673e27997cb783ef3a7f827de974a18d858/docs/make.jl#L39-L66

@dourouc05
Copy link
Contributor Author

I've converted the tutorial into doctests. I checked them in the REPL while working on it, I hope the tests will pass…

@dourouc05
Copy link
Contributor Author

@odow Could you please have a look at the current failures? It really looks like different versions of Julia have different outputs regarding types.

@odow
Copy link
Member

odow commented Aug 25, 2021

Yeah the docs run in Julia 1.0, which has different printing.

A secret is to run this in Julia 1.0 and it will fix everything:

"""
Pass `julia docs/make.jl --fix` to rebuild the doctests.
"""
const _FIX = findfirst(isequal("--fix"), ARGS) !== nothing

@dourouc05
Copy link
Contributor Author

It now seems to pass :D!

Copy link
Member

@odow odow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. A couple of points.

@odow odow added the Type: Documentation This issue requires changes to the documentation label Aug 25, 2021
Returns an iterator for the scalar components of the vector function.
See also [`scalarize`](@ref).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this worked. I thought it had to be [`Utilities.scalarize`](@ref)

Copy link
Member

@odow odow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Much better than before!

@odow odow merged commit 4400b70 into jump-dev:master Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Documentation This issue requires changes to the documentation
Development

Successfully merging this pull request may close these issues.

3 participants