Skip to content

Use a proper lexer for hiding code in doctests #84478

Closed
@jyn514

Description

@jyn514

Right now, rustdoc uses line-by-line heuristics to tell if a line should be hidden. That has false positives with multi-line strings, e.g.

let s = "hello
# because why not?";

and soon, after #84445,

let s = "hello
#because why not?";

It would be nice to use a proper lexer so we can detect where strings start and end instead of having to do custom "parsing".

Originally posted by @GuillaumeGomez in #84445 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: Documentation tests, run by rustdocT-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

    No branches or pull requests

    Issue actions