burn icon indicating copy to clipboard operation
burn copied to clipboard

Add `source` button in Docs

Open Arjun31415 opened this issue 1 year ago • 6 comments

The source button present in docs for tch-rs as a sample - image

No such button for burn-rs docs image

It would greatly help looking into pin-pointing the definition and implementation of modules in this vast repo

Arjun31415 avatar Feb 03 '24 15:02 Arjun31415

It's available on docs.rs, we are probably missing a feature flag when building the docs, but I'm not able to find it.

nathanielsimard avatar Feb 05 '24 15:02 nathanielsimard

It's not a feature flag that is missing here but the fact that the burn package's docs are build with --no-deps. While rustdoc still expands and documents re-exported items (in this case these from burn-core), it can't produce the source links to the code of the dependency. Docs.rs doesn't suffer from this as it generates the docs for every uploaded library crate and interlinks them (including the links to the source code).

I wasn't able to find where the API docs are build in the CI, are they build manually? I think the most sensible fix would be to build the whole workspace instead of just the burn package for the API docs. Or build the burn package without the --no-deps flag. The former can be done with --no-deps to avoid 3rd-party crates to be added to the docs, which should be fine if burn doesn't re-export any items from them. If it does, the source links for said items would be missing again. Maybe something like cargo doc -p burn -p burn-core -p burn-train --no-deps would be enough to add the source links to every item, I haven't checked whether burn-core or burn-train re-export any items themselves.

jofas avatar Mar 13 '24 12:03 jofas

Tagging @Luni-4 @syl20bnr

antimora avatar Mar 13 '24 14:03 antimora

@jofas analysis is correct. If I remember correctly, we have removed the --no-deps option because of the great amount of time in bulding the docs. Here and here are the function calls, even used on CI.

Since documentation should be independent from any operating systems (@nathanielsimard @antimora @louisfd please confirm whether my previous statement is correct for what concerns burn), a possible solution might be the creation of a specific documentation task. This task can be run both locally and on CI. This kind of task:

  • Does not run cargo doc ... command for each operating system
  • Runs a specific virtual machine in parallel only for the documentation
  • Allows to be re-used for the publish workflow

What do you think @syl20bnr?

Luni-4 avatar Mar 13 '24 17:03 Luni-4

This might be outdated? I see currently source links in the docs: https://docs.rs/burn/latest/burn/nn/conv/struct.Conv2d.html

ivnsch avatar Sep 12 '24 05:09 ivnsch

This issue is about the docs hosted on burn.dev, which are missing the source buttons.

jofas avatar Sep 12 '24 06:09 jofas