Zulip Chat Archive

Stream: lean4

Topic: how to generate html documentation for new lean file


Yufei Liu (Jan 21 2024 at 08:56):

Hi everyone,

I've created a new .lean file with new theorems using existing theorems from Mathlib's linear algebra section only in proof. Now, I'm looking to document this theorem in HTML format, similar to the existing Lean Mathlib Documentation.

Is there a way to generate this specific documentation?

Marcus Rossel (Jan 21 2024 at 09:15):

https://github.com/leanprover/doc-gen4

Yufei Liu (Jan 21 2024 at 09:44):

Marcus Rossel said:

https://github.com/leanprover/doc-gen4

thanks, ive come across this, but when i run:
lake -R -Kenv=dev build Test:docs
it has an error:
error: unknown short option '-R'

what does it mean?

Henrik Böving (Jan 21 2024 at 10:45):

That your lean version is too old most likely.

Yufei Liu (Jan 21 2024 at 13:09):

how do i check my lean version and how do i update?

Henrik Böving (Jan 21 2024 at 13:10):

It's in the lean-toolchain file of your projct

Yufei Liu (Jan 21 2024 at 13:10):

thanks, it's leanprover/lean4:v4.0.0, how do i update

Ruben Van de Velde (Jan 21 2024 at 13:44):

Do you use mathlib as a dependency?

Yufei Liu (Jan 21 2024 at 14:35):

nope i just clone the whole repo

Yufei Liu (Jan 21 2024 at 14:35):

should i use it as dependency?

Ruben Van de Velde (Jan 21 2024 at 14:48):

Either could work, but the advice will depend on your situation

Ruben Van de Velde (Jan 21 2024 at 14:49):

Can't check right now, but you should be able to find how mathlib generates documentation and just use that

Yufei Liu (Feb 05 2024 at 14:29):

i just cloned a whole brand new branch from master branch
and i try to run
lake -Kdoc=on build Mathlib:docs
but got error:
error: unknown library facet docs``
why is that?

Henrik Böving (Feb 05 2024 at 16:46):

The R flag is missing

Yufei Liu (Feb 06 2024 at 09:57):

thanks, that fixed the problem

another question i have is what if i only want to build part of mathlib?

for example: lake -R -Kdoc=on build Mathlib/LinearAlgebra:docs
is that the right thing to do (seems like not, it'll return unknown target error)

Brendan Seamas Murphy (Feb 07 2024 at 03:49):

Henrik Böving said:

The R flag is missing

Ah it looks like it's missing in the mathlib github readme. What does adding this flag do?

Henrik Böving (Feb 07 2024 at 07:13):

As per a design decision made a little while back the -K stuff is not a one time CLI thing but instead a cmake style configuration flag. That means that you explicitly have to reconfigure (that's -R) the lake project with that flag.

Mario Carneiro (Feb 07 2024 at 12:03):

I think I managed to convince @Mac Malone to change that a while ago, although I think nothing has happened to the implementation yet. Probably there should be an issue tracking it if there isn't already

Yufei Liu (Mar 18 2024 at 02:45):

still have this quesion:

  1. what do i do if i only want to build part of mathlib?

for example: lake -R -Kdoc=on build Mathlib/LinearAlgebra:docs
is that the right thing to do (seems like not, it'll return unknown target error)

and also i have some new problems:

  1. I simply add a new .lean file inside the Mathlib folder, and after I run lake -R -Kdoc=on build Mathlib:docs, seems like the new .lean file does not appeer in the doc folder, why is that?

thanks

Kim Morrison (Mar 18 2024 at 02:47):

You specify the targets as module names, e.g. lake build Mathlib.LinearAlgebra.Basic

Kim Morrison (Mar 18 2024 at 02:49):

If you add a new Lean file, you must also import it in Mathlib.lean.

Yufei Liu (Mar 18 2024 at 17:24):

thanks, that solved the problem


Last updated: May 02 2025 at 03:31 UTC