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

Add TreeSet example #15668

Merged
merged 1 commit into from
Jul 17, 2014
Merged

Add TreeSet example #15668

merged 1 commit into from
Jul 17, 2014

Conversation

steveklabnik
Copy link
Member

Someone asked for an example usage of this on IRC, so I tossed together the simplest one. Obviously, this isn't up to snuff, but it's better than nothing.

//! for i in tree_set.iter() {
//! println!("{}", i)
//! }
//!```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should go on the TreeSet struct definition instead?

You may also want to mix up the order of inserts and then comment saying that it prints 1 2 3

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. It's nice to have a very simple example as the module definition, what do you think about both places?

And yeah, mixing it up sounds good.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't really figured out the best way to do this yet, for example the hashmap type has a small module description but a large type description.

On the other hand, the result module has a large description while the type has a small description.

I suppose as long as it's somewhere it's ok. I think for collections they're susceptible to being reexported a good bit, so maybe reexported things favor the type while other things (like result) are up in the air?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, that might be a decent heuristic.

One thing that comes up is http://doc.rust-lang.org/std/collections/hashmap/index.html comes up before http://doc.rust-lang.org/std/collections/hashmap/struct.HashMap.html when you search for 'hashmap', which I've always found a bit irritating. I think I prefer having at least some kind of reasonable overview on the module. Ideally each of these pages lives mostly on its own, with the module having overview and the type having just details.

@steveklabnik
Copy link
Member Author

I've made the operations out of order, and added the definition to both. Eventually, I'll write more for the module reference.

@@ -12,6 +12,19 @@
//! trees. The only requirement for the types is that the key implements
//! `Ord`.

//! ## Example
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this render correctly? (I'm not sure if markdown handles a paragraph directly running into a heading, since there's no //! on the previous line.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not get friggin' rustdoc to generate any documentation on this file, complaining about glob imports and such. I also tried to run it on src/libcollections/lib.rs, and same deal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, you'll definitely have to run it on the whole crate rather than just this module, not sure about the other error.

Maybe make doc/collections/index.html NO_REBUILD=1? (I'm not 100% sure if NO_REBUILD works with that target.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On that note, these examples will need the appropriate imports (I guess just TreeSet).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, I thought that lib.rs was the crate. Lemme check this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What were the errors you ran into when running rustdoc src/libcollections/lib.rs? Also, if you want to run the tests, you can just run rustdoc --test src/libcollections/lib.rs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Oh, yeah, I just meant running on treemap.rs in isolation wasn't going to work... your other lib.rs invocation is the only one that has a reasonable hope of succeeding.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, now, of course, running rustdoc on lib.rs does work. I have re-compiled rustc between then and now, and I basically assumed that was probably the problem.

This does not render correctly, but adding a //! in doesn't seem to fix it either.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you need a blank line (i.e. //!) before and after? I'm not sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops:

@@ -11,8 +11,9 @@
 //! An ordered map and set implemented as self-balancing binary search
 //! trees. The only requirement for the types is that the key implements
 //! `Ord`.
-
+//!
 //! ## Example
+//!
 //! ```{rust} 
 //! let mut tree_set = TreeSet::new();
 //!    
@@ -23,7 +24,7 @@
 //! for i in tree_set.iter() {
 //!    println!("{}", i) // prints 1, then 2, then 3
 //! }
-//!```
+//! ```

Pushing fix now.

@steveklabnik
Copy link
Member Author

@alexcrichton since I force pushed, your retry isn't gonna work, I bet. Unless bors is super smart?

@alexcrichton
Copy link
Member

I think these will still need to import TreeSet, have the tests passed for you?

@steveklabnik
Copy link
Member Author

of course! Ignore the fact that I had to force push one more time to add that because I forgot the --test on rustdoc!

Thank $DIETY for @bors, that's all I have to say.

@steveklabnik
Copy link
Member Author

Ugh, don't know how that whitespace got in there. @alexcrichton , it is now fixed.

@steveklabnik
Copy link
Member Author

Good to go again.

bors added a commit that referenced this pull request Jul 17, 2014
…hton

Someone asked for an example usage of this on IRC, so I tossed together the simplest one. Obviously, this isn't up to snuff, but it's better than nothing.
@bors bors closed this Jul 17, 2014
@bors bors merged commit ace3a77 into rust-lang:master Jul 17, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 13, 2023
…ykril

feat: add backtick to surrounding and auto-closing pairs

Makes backticks always complete as a pair and also surround the current selection, similar to double quotes. This is useful primarily in the context of markdown doc comments, but is applied globally for simplicity.

Closes rust-lang/rust-analyzer#11381
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.

4 participants