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 a way to ignore links #31

Closed
jyn514 opened this issue Nov 14, 2020 · 10 comments
Closed

Add a way to ignore links #31

jyn514 opened this issue Nov 14, 2020 · 10 comments
Labels
enhancement New feature or request

Comments

@jyn514
Copy link
Contributor

jyn514 commented Nov 14, 2020

Currently, every time I run intraconv, it changes this link:

-    /// [`downcast_ref`]: #method.downcast_ref
+    /// [`downcast_ref`]: Collect::downcast_ref()

That breaks because downcast_ref is a function on dyn Collect, not Collect itself. There's no way for intra-conv to know this, so I don't think it can be fixed on that end, but it would be nice to say "I know this link will break, don't convert it" with a configuration file or something.

Similarly

//! [span]: https://docs.rs/tracing/latest/tracing/span/index.html
//! [span]: tracing::span

gets converted every time, which breaks because tracing isn't in scope in tracing-attributes (rust-lang/rust#74481).

@poliorcetics
Copy link
Owner

This may become verbose quickly if this is a command line option.

I'm not sure how to do it properly, maybe through a file and a --ignore-links [FILE]

@poliorcetics poliorcetics added the enhancement New feature or request label Nov 14, 2020
@jyn514
Copy link
Contributor Author

jyn514 commented Nov 14, 2020

Yeah, a file sounds nice - I was imagining this as configurable per-file and per-link so it would definitely be annoying to type by hand.

@poliorcetics
Copy link
Owner

poliorcetics commented Nov 14, 2020

What would you want from such a file ? I have no idea about the format I'll use

Edit: What features are you thinking about ?

@jyn514
Copy link
Contributor Author

jyn514 commented Nov 14, 2020

I was imagining something like this:

[ignore]
[["tracing/src/lib.rs"]]
"`downcast_ref`" = "#method.downcast_ref"

(I checked and that's valid toml.)

@poliorcetics
Copy link
Owner

Oh nice, if TOML is usable I'll juste use the toml crate and it will be easier (and more solid) than parsing a wonky format.

@poliorcetics
Copy link
Owner

I'm wondering, would it be more intuitive to use suffixes (mod.rs can match multiple times) or canonicalised paths (mod.rs has been expanded to exactly one file) for the configuration file and the behaviour of intraconv ? What would you expect ?

@jyn514
Copy link
Contributor Author

jyn514 commented Nov 18, 2020

Maybe it should use .gitignore syntax? Where you can say /tracing/src/mod.rs to mean an absolute path and mod.rs to mean a relative one, possibly matching many files.

@poliorcetics
Copy link
Owner

Nice idea, I'll go with that !

@poliorcetics
Copy link
Owner

poliorcetics commented Nov 18, 2020

❯ cg intraconv -i intraconv.toml tracing-core
/Users/alexis/Projects/rust/tracing/tracing-core/src/collect.rs
===============================================================

  443:  "    /// [`downcast_ref`]: #method.downcast_ref"
        "    /// [`downcast_ref`]: Collect::downcast_ref()"

/Users/alexis/Projects/rust/tracing/tracing-core/src/event.rs
=============================================================

   20:  "/// [span]: ../span"
        "/// [span]: super::span"

   21:  "/// [fields]: ../field"
        "/// [fields]: super::field"

/Users/alexis/Projects/rust/tracing/tracing-core/src/lib.rs
===========================================================

   93:  "//! [`libstd`]: https://doc.rust-lang.org/std/index.html"
        "//! [`libstd`]: crate"

  107:  "//! [`liballoc`]: https://doc.rust-lang.org/alloc/index.html"
        "//! [`liballoc`]: alloc"

~/P/r/tracing on  master via  v1.47.0 
❯ cg intraconv tracing-core    
+/Users/alexis/Projects/rust/tracing/tracing-core/src/collect.rs
+===============================================================
+
+  443:  "    /// [`downcast_ref`]: #method.downcast_ref"
+        "    /// [`downcast_ref`]: Collect::downcast_ref()"
+
/Users/alexis/Projects/rust/tracing/tracing-core/src/event.rs
=============================================================

   20:  "/// [span]: ../span"
        "/// [span]: super::span"

   21:  "/// [fields]: ../field"
        "/// [fields]: super::field"

/Users/alexis/Projects/rust/tracing/tracing-core/src/lib.rs
===========================================================

   93:  "//! [`libstd`]: https://doc.rust-lang.org/std/index.html"
        "//! [`libstd`]: crate"

  107:  "//! [`liballoc`]: https://doc.rust-lang.org/alloc/index.html"
        "//! [`liballoc`]: alloc"

With and without the ignore file. I just have to document it properly in the README and I'll push the changes.

@poliorcetics
Copy link
Owner

   93:  "//! [`libstd`]: https://doc.rust-lang.org/std/index.html"
        "//! [`libstd`]: crate"

Another instance of #32 😓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants