Skip to content

Link to docs.rs if no documentation is provided #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented Jan 19, 2017

/r/golang asked if we autolink to docs.rs, and we don't, but I think that's a really good idea!

I'm only touching UI code here so that the "default" docs.rs links don't filter down to the models and then the database.

r? @steveklabnik @wycats @carols10cents

@Manishearth
Copy link
Member Author

This does not update https://crates.io/crates/url/docs ; I'm not sure if it should.

@carols10cents
Copy link
Member

I think this has the same problems as #459, namely that:

  • There's not a way to opt-out, other than specifying your own documentation link
  • There's not a way to NOT generate this link if docs.rs failed to build the docs :-/

@onur
Copy link
Member

onur commented Jan 20, 2017

Hi Carol. I actually asked you about this but didn't get a reply. I can provide built info with a CORS header so crates.io can check if a doc successfully built or not.

@Manishearth
Copy link
Member Author

@onur that would be great, thanks!

onur added a commit to rust-lang/docs.rs that referenced this pull request Jan 20, 2017
Docs.rs will provide build as json from following URL:

`https://docs.rs/crate/<CRATE_NAME>/<CRATE_VERSION>/builds.json`.

A get request to this URL will return a list of build attempts. First
object in this list will always contain latest build attempt. This
object will contain following fields:

Example output of `https://docs.rs/crate/rand/0.3.15/builds.json`:

```json
[
  {
    "build_status":true,
    "build_time":"2016-12-29T10:10:49Z",
    "build_time_relative":"Dec 29, 2016",
    "cratesfyi_version":"cratesfyi 0.2.3 (eea831c 2016-12-29)",
    "id":1,
    "output":null,
    "rustc_version":"rustc 1.15.0-nightly (71c06a56a 2016-12-18)"
  }
]
```

`build_status` is `true` if docs.rs successfully built documentation of
a crate and `false` if docs.rs failed to build or a crate doesn't have
any documentation.

This list will contain zero elements if requested crate doesn't exists
in docs.rs.

Fixes: #87
Ref: rust-lang/crates.io#459
Ref: rust-lang/crates.io#506
@onur
Copy link
Member

onur commented Jan 20, 2017

Docs.rs is providing build info as json from following URL now:

https://docs.rs/crate/<CRATE_NAME>/<CRATE_VERSION>/builds.json.

It is also sending Access-Control-Allow-Origin: * header, it must be
ok to query this URL from crates.io.

A get request to this URL will return a list of build attempts. First
object in this list will always contain latest build attempt. This
object will contain following fields:

Example output of https://docs.rs/crate/rand/0.3.15/builds.json:

[
  {
    "build_status":true,
    "build_time":"2016-12-29T10:10:49Z",
    "build_time_relative":"Dec 29, 2016",
    "cratesfyi_version":"cratesfyi 0.2.3 (eea831c 2016-12-29)",
    "id":1,
    "output":null,
    "rustc_version":"rustc 1.15.0-nightly (71c06a56a 2016-12-18)"
  }
]

build_status is true if docs.rs successfully built documentation of
a crate and false if docs.rs failed to build or a crate doesn't have
any documentation.

This list will contain zero elements if requested crate doesn't exists
in docs.rs (building a crate is usually taking 1-10 minutes for new
releases).

@carols10cents
Copy link
Member

@onur great! I'm a little concerned about the number of ajax requests that'll happen when loading a list of crates, but I think someone will have to try it out and see!

I'm going to close this one and #459 then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants