Skip to content
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

Partial include should show full file instead of stub when showing hidden lines. #618

Closed
shingtaklam1324 opened this issue Feb 12, 2018 · 2 comments · Fixed by #1003
Closed

Comments

@shingtaklam1324
Copy link

Currently, when parts of the code is included, the default stub is included.

@Michael-F-Bryan
Copy link
Contributor

Would you be able to show us an example of what you see versus what you expected to happen?

@carols10cents
Copy link
Member

Ok I think I understand this one because I think I'm having the same issue.

When I have an external file that, say, looks like this:

struct User {
    username: String,
    email: String,
    sign_in_count: u64,
    active: bool,
}

fn main() {
    let user1 = User {
        email: String::from("[email protected]"),
        username: String::from("someusername123"),
        active: true,
        sign_in_count: 1,
    };
}

And I include part of the file like this:

```rust
{{#include ../examples/ch05-using-structs-to-structure-related-data/listing-05-02/src/main.rs:9:14}}
```

I correctly see the part of the file rendered:

Screen Shot 2019-04-28 at 3 36 15 PM

But when I click the "show hidden lines" link, I see this:

Screen Shot 2019-04-28 at 3 37 32 PM

The example has been wrapped in main and the allow(unused_variables) has been added. I think that's what @shingtaklam1324 means by "default stub".

What would be nice is if clicking the "show hidden lines" link expanded to show the rest of the file instead, and only wrapping in main if the rest of the file didn't have main.

I'm working on extracting TRPL's examples into external files, and this would be really nice to have. I'll probably give this a try soon.

carols10cents added a commit to integer32llc/mdBook that referenced this issue Aug 23, 2019
Dylan-DPC-zz pushed a commit that referenced this issue Oct 5, 2019
* Allow underscores in the link type name

* Add some tests for include anchors

* Include parts of Rust files and hide the rest

Fixes #618.

* Increase min supported Rust version to 1.35

* Add a test for a behavior of rustdoc_include I want to depend on

At first I thought this was a bug, but then I looked at some use cases
we have in TRPL and decided this was a feature that I'd like to use.
Ruin0x11 pushed a commit to Ruin0x11/mdBook that referenced this issue Aug 30, 2020
* Allow underscores in the link type name

* Add some tests for include anchors

* Include parts of Rust files and hide the rest

Fixes rust-lang#618.

* Increase min supported Rust version to 1.35

* Add a test for a behavior of rustdoc_include I want to depend on

At first I thought this was a bug, but then I looked at some use cases
we have in TRPL and decided this was a feature that I'd like to use.
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 a pull request may close this issue.

3 participants