-
Notifications
You must be signed in to change notification settings - Fork 700
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
rename pallet struct in #[cfg(doc)]
#191
Comments
Then rename the |
where to start for this issue? |
I would second what @bkchr said that we should actually name the pallet struct something meaningful. This could potentially be done by tweaking the pallet expansion code to be OK with this, i.e:
This will force you to use a name other than I would also prefer that this pallet struct ident be extremely accessible, probably on the root pallet |
@sam0x17 as it, we cannot rename Ideally, I would name Your point about logging is also correct. We may be able to can auto-generate a |
@kianenigma yeah no problem I will do it |
You are working everywhere to make it less magic and then you want to generate a |
My point was more that the pallet name should be accessible enough both at runtime and compile-time that something automatic can hook into it instead of _needing_ to do something like `LOG_TARGET` in every crate
|
You don't know the pallet name at compile time. We moved away from this assumption quite some time ago. The pallet name is set in the runtime. You can name your stuff
|
FYI, |
Why did we move away from this. Seems like a step backward? |
I mean the name of the pallet. This name is used for example to prefix the storage items to make them unique. You could call the pallet struct as you like. But there can be multiple instances of the same pallet and each of it having a different name in the runtime. |
OK so these two things are de-coupled because instancing can give the pallet different names at runtime. This doesn't mean we can't also have a name at compile-time that can be relied on for various purposes and that doesn't necessairly track with the instancing name used at runtime. Beter to have that than just "well we know it is a pallet and that is about it". This compile-time name could also act as a default for the runtime name, allowing it to go unspecified unless it needs to be overridden at runtime because of instancing/etc. |
You specify a name any way in the runtime, always, by default. No need to have some "other" default option. As I said, support renaming |
I think we're going a bit on a sidetrack here. Seems like we agree on "let's rename The log matter is entirely different because it is not a function of the name of the pallet struct, and is instead a function of the name that the pallet is given at by the top level runtime. Even if something can be done about a nicer logging, it is a different concern (again, because it has nothing to do with |
in the doc, hovering over the name will give the full path. This helps a little. But I agree seeing Maybe all item could be named for consistency: EDIT: Also we don't need to make it mandatory. |
Another idea could be to force those specific types to be rendered with their full path in the doc. |
Result doesn't render very good I think: I tried to make those specific items to always render with full path in librustdoc in rustc diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index f26d74629dd..14c49fe3a55 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -801,6 +801,14 @@ fn resolved_path<'cx>(
) -> fmt::Result {
let last = path.segments.last().unwrap();
+ let last_name_as_str = last.name.as_str();
+ let force_absolute = last_name_as_str == "Pallet"
+ || last_name_as_str == "Config"
+ || last_name_as_str == "GenesisConfig"
+ || last_name_as_str == "Event"
+ || last_name_as_str == "Error"
+ || last_name_as_str == "Runtime";
+
if print_all {
for seg in &path.segments[..path.segments.len() - 1] {
write!(w, "{}::", if seg.name == kw::PathRoot { "" } else { seg.name.as_str() })?;
@@ -809,7 +817,7 @@ fn resolved_path<'cx>(
if w.alternate() {
write!(w, "{}{:#}", &last.name, last.args.print(cx))?;
} else {
- let path = if use_absolute {
+ let path = if use_absolute || force_absolute {
if let Ok((_, _, fqp)) = href(did, cx) {
format!(
"{}::{}", but the result is too verbose, maybe only use absolute path for type in foreign crate |
This is great exploration @thiolliere, thanks for sharing your outcomes. Possibly, we can couple this with the rest of ideas in paritytech/polkadot-sdk-docs#12, and maintain our our little fork of |
I hope this is a joke ;) |
In general I agree that this, while being somewhat useful for docs, is too much magic and can cause more confusion than help. Closing. Someday, if we are to revise again, it is probably easiest to do it via injecting a custom JS into the doc header. |
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
* expose metrics for Prometheus * added preconfigured configs for Prometheus and Grafana * metrics-related cli args * fix compilation
... to something that represents the pallet itself, for example
PalletBalances
orBalancesPallet
instead ofPallet
. The reason for this is that reading pages like this is kinda hard:Although, I am also mildly worried that this will bring about more confusion that being helpful.
The text was updated successfully, but these errors were encountered: