Skip to content

Include images in rustdoc output #32104

@emoon

Description

@emoon
Contributor

As written by Luthaf over here

https://users.rust-lang.org/t/include-images-in-rustdoc-output/3487

"Hi rustaceans!

Images in documentation can be really useful to provide some insight on algorithms or modules organisation.

It is already possible to insert a link to an image in documentation comment

/// ![Alt version](url://for/this/image.png)

But using this method, we only get to include images already available in some place of Internet.

Is it a way to make rustdoc copy some files to the target/doc folder, so that it is easy to include specific images in the documentation? The same could go for other static files, like specific CSS or JS.

Is it possible yet? If not, do you think it is worth it?"

I this this would be awesome to include as sometimes using images is much easier when explain something than showing text.

Activity

bluss

bluss commented on Mar 7, 2016

@bluss
Member

I second this, images can greatly help explaining (geometrical split_at example).

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on Mar 11, 2016
added
T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.
and removed on May 18, 2017
jimblandy

jimblandy commented on Apr 26, 2018

@jimblandy
Contributor

Since the focus is on doxidize now, rustdoc is in maintenance-only mode. Should this be closed?

cc: @steveklabnik

steveklabnik

steveklabnik commented on Apr 26, 2018

@steveklabnik
Member

I'd say "maintenance-only" mode is a bit strong; rustdoc has its own team and they're still working on new stuff. It's entirely possible that this will get added to rustdoc.

TotalKrill

TotalKrill commented on Jul 30, 2018

@TotalKrill

Would love this as well! Has there been any updates?

ZhangHanDong

ZhangHanDong commented on Nov 21, 2018

@ZhangHanDong

It‘s work

//! <div>
//! <img src="../../../images/rustbook.jpg" height="300" width="220" />
//! </div>
//! <hr/>
crepererum

crepererum commented on Nov 22, 2018

@crepererum
Contributor

That only works locally if you're building the docs for your own crate. Does not work on docs.rs or if the crate is a dependency of something else.

Background:
The referred image is not copied / tracked.

ZhangHanDong

ZhangHanDong commented on Dec 1, 2018

@ZhangHanDong

@crepererum you're right. One solution is to separate the doc file and manually modify it.

crepererum

crepererum commented on Dec 1, 2018

@crepererum
Contributor

Or you host the image somewhere, like on GitHub pages (that's what ndarray is doing here https://github.com/rust-ndarray/ndarray/blob/master/src/impl_views.rs )

TotalKrill

TotalKrill commented on Dec 22, 2018

@TotalKrill

I think what would be most optimal is if there could be a folder where images for the doc could be stored in the crate folder structure.

There is one huge painpoint here though, and that is a lot of people just love to generate extremely large pictures to include in the crates. For no reason: ClickBait article with example

So if this should be in the code, the file size should be limited.

60 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @steveklabnik@ZhangHanDong@ehuss@sanxiyn@dherman

    Issue actions

      Include images in rustdoc output · Issue #32104 · rust-lang/rust