Stream: rustdoc

Topic: what is CURRENT_DEPTH


view this post on Zulip Noah Lev (Mar 03 2021 at 19:03):

What is CURRENT_DEPTH? There's a comment in the HTML renderer about it:

        // A little unfortunate that this is done like this, but it sure
        // does make formatting *a lot* nicer.
        CURRENT_DEPTH.with(|slot| {
            slot.set(self.current.len());
        });

but I'm not sure what it means by "it sure does make formatting a lot nicer". It seems like it's used to find how nested the current item is, and it's used for ../ links?

view this post on Zulip Noah Lev (Mar 03 2021 at 19:05):

It's used from clean/types.rs, which is a bit weird since IIUC clean/types.rs is supposed to be format-independent.

view this post on Zulip Noah Lev (Mar 03 2021 at 19:05):

Specifically it's used in Item::links()—maybe that should be moved to html/render/?

view this post on Zulip Noah Lev (Mar 03 2021 at 19:20):

Wow, CURRENT_DEPTH has literally been around since when String was called StrBuf... oh my

view this post on Zulip Noah Lev (Mar 03 2021 at 19:20):

And it was around when StrBuf was called ~str...

view this post on Zulip Noah Lev (Mar 03 2021 at 19:21):

And it's been around since the beginning of the rustdoc HTML backend. No wonder it's so hard to refactor :laughing:

view this post on Zulip Noah Lev (Mar 03 2021 at 19:21):

Huh, apparently rustdoc_ng's original backend was JSON

view this post on Zulip Noah Lev (Mar 03 2021 at 19:23):

Looks like Alex Crichton is the one that added that "a little unfortunate" comment—in 2013.

view this post on Zulip GuillaumeGomez (Mar 03 2021 at 19:43):

It was there when I arrived. It's about adding the .. iirc

view this post on Zulip GuillaumeGomez (Mar 03 2021 at 19:43):

Not sure why they used a global for that though...

view this post on Zulip Noah Lev (Mar 04 2021 at 02:51):

Yeah, unfortunately it's hard to remove now.

view this post on Zulip Noah Lev (Mar 04 2021 at 02:51):

But we'll figure it out!

view this post on Zulip Noah Lev (Mar 04 2021 at 02:51):

I do still feel confused about the "it sure makes formatting a lot nicer" comment, but oh well.

view this post on Zulip GuillaumeGomez (Mar 04 2021 at 08:46):

It was another time, don't try to understand the past haha


Last updated: Oct 11 2021 at 22:34 UTC