Stream: rustdoc

Topic: skip doctests attribute?


view this post on Zulip Mario Carneiro (Dec 03 2020 at 22:16):

I didn't see mention of this in the docs, so perhaps someone here knows if it's possible to mark all doc tests as ```ignore in a scope using attributes. I'm currently using some macro magic to duplicate the doc comment in another venue that can read markdown, and the code snippets are not actually rust code.

view this post on Zulip Noah Lev (Dec 03 2020 at 22:17):

Btw, if it's not Rust and you don't want Rust syntax highlighting, you can use the text language ( ```text).

view this post on Zulip Mario Carneiro (Dec 03 2020 at 22:18):

I can't do that because they aren't text either, and the other doc tool that is reading it has a different default language

view this post on Zulip Joshua Nelson (Dec 03 2020 at 22:19):

I don't think there's a way to do this.

view this post on Zulip Mario Carneiro (Dec 03 2020 at 22:19):

dang

view this post on Zulip Mario Carneiro (Dec 03 2020 at 22:19):

what does rustdoc do with unrecognized languages?

view this post on Zulip Poliorcetics (Dec 03 2020 at 22:20):

Doesn't highlight them nor run tests

view this post on Zulip Mario Carneiro (Dec 03 2020 at 22:21):

I guess that should be alright

view this post on Zulip Poliorcetics (Dec 03 2020 at 22:22):

I'm not exactly sure but I believe it just inject the raw source (barring # code lines)

view this post on Zulip Mario Carneiro (Dec 03 2020 at 22:22):

...but it's markdown?

view this post on Zulip Mario Carneiro (Dec 03 2020 at 22:22):

something has to render it

view this post on Zulip Poliorcetics (Dec 03 2020 at 22:23):

well yes, but it doesn't add blocks inside the <pre> code block (when outputting html)

view this post on Zulip Mario Carneiro (Dec 03 2020 at 22:24):

ah gotcha

view this post on Zulip Mario Carneiro (Dec 03 2020 at 22:24):

It still does # stripping even on unrecognized languages?

view this post on Zulip Poliorcetics (Dec 03 2020 at 22:24):

I'm currently editing the file for highlighting, it only handles rust, the rest is just pasted betwen <pre>

view this post on Zulip Poliorcetics (Dec 03 2020 at 22:24):

Mario Carneiro said:

It still does # stripping even on unrecognized languages?

Not sure

view this post on Zulip Mario Carneiro (Dec 03 2020 at 22:25):

well there's escaping so I guess the fallout from that isn't too bad

view this post on Zulip Poliorcetics (Dec 03 2020 at 22:27):

/// ```c
/// # static int a = 0;
/// int main(void) {
///     return 0;
/// }
/// ```
fn main() {
}

touch src/main.rs; cg doc --no-deps; cat target/doc/playground/fn.main.html

Output:

<code class="language-c"># static int a = 0;
int main(void) {
    return 0;
}
</code>

view this post on Zulip Poliorcetics (Dec 03 2020 at 22:28):

so # lines are not ignored

view this post on Zulip Poliorcetics (Dec 03 2020 at 22:28):

(cg is my local alias for cargo)

view this post on Zulip Noah Lev (Dec 03 2020 at 23:11):

Related to cg: I also recently learned that you can do cargo r, cargo b, cargo c, and cargo t for run, build, check, and test. So you could do cg r with your setup! (Though cargo d doesn't do cargo doc)

view this post on Zulip Poliorcetics (Dec 03 2020 at 23:12):

Camelid said:

Related to cg: I also recently learned that you can do cargo r, cargo b, cargo c, and cargo t for run, build, check, and test. So you could do cg r with your setup! (Though cargo d doesn't do cargo doc)

Well I do cgr (no space) because I have tons of aliases

view this post on Zulip Poliorcetics (Dec 03 2020 at 23:13):

git is g

view this post on Zulip Poliorcetics (Dec 03 2020 at 23:14):

Aliases are life, I type cg so much

view this post on Zulip Noah Lev (Dec 03 2020 at 23:19):

I have gst for git status -- g=git is a good idea :)


Last updated: Oct 11 2021 at 22:34 UTC