-
Notifications
You must be signed in to change notification settings - Fork 742
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation around FRAME Origin (#3362)
Does the following: - Add a reference doc page named `frame_runtime_types`, which explains what types like `RuntimeOrigin`, `RuntimeCall` etc are. - On top of it, it adds a reference doc page called `frame_origin` which explains a few important patterns that we use around origins - And finally brushes up `#[frame::origin]` docs. - Updates the theme, sidebar and favicon to look like: <img width="1728" alt="Screenshot 2024-02-20 at 12 16 00" src="https://github.com/paritytech/polkadot-sdk/assets/5588131/6d60a16b-2081-411b-8869-43b91920cca9"> All of this was inspired by https://substrate.stackexchange.com/questions/10992/how-do-you-find-the-public-key-for-the-medium-spender-track-origin/10993 closes paritytech/polkadot-sdk-docs#45 closes paritytech/polkadot-sdk-docs#43 contributes / overlaps with #2638 cc @liamaharon deprecation companion: polkadot-developers/substrate-docs#2131 pba-content companion: Polkadot-Blockchain-Academy/pba-content#977 --------- Co-authored-by: Radha <[email protected]> Co-authored-by: Sebastian Kunert <[email protected]> Co-authored-by: Gonçalo Pestana <[email protected]> Co-authored-by: Liam Aharon <[email protected]>
- Loading branch information
1 parent
f5de090
commit ad01d70
Showing
21 changed files
with
839 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
flowchart LR | ||
RuntimeCall --"TryInto"--> PalletCall | ||
PalletCall --"Into"--> RuntimeCall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<script> | ||
function createToC() { | ||
let sidebar = document.querySelector(".sidebar"); | ||
let headers = document.querySelectorAll("#main-content h2, #main-content h3, #main-content h4"); | ||
console.log(`detected polkadot_sdk_docs: headers: ${headers.length}`); | ||
|
||
let toc = document.createElement("div"); | ||
toc.classList.add("sidebar-table-of-contents"); | ||
toc.appendChild(document.createElement("h2").appendChild(document.createTextNode("Table of Contents")).parentNode); | ||
|
||
let modules = document.querySelectorAll("main .item-table a.mod"); | ||
|
||
// the first two headers are always junk | ||
headers.forEach(header => { | ||
let link = document.createElement("a"); | ||
link.href = "#" + header.id; | ||
link.textContent = header.textContent; | ||
link.className = header.tagName.toLowerCase(); | ||
|
||
toc.appendChild(link); | ||
|
||
if (header.id == "modules" && header.textContent == "Modules") { | ||
modules.forEach(module => { | ||
let link = document.createElement("a"); | ||
link.href = module.href; | ||
link.textContent = module.textContent; | ||
link.className = "h3"; | ||
|
||
toc.appendChild(link); | ||
}); | ||
} | ||
}); | ||
|
||
// insert toc as the second child in sidebar | ||
let sidebar_children = sidebar.children; | ||
if (sidebar_children.length > 1) { | ||
sidebar.insertBefore(toc, sidebar_children[1]); | ||
} else { | ||
sidebar.appendChild(toc); | ||
} | ||
} | ||
|
||
function hideSidebarElements() { | ||
// Create the 'Expand for More' button | ||
var expandButton = document.createElement('button'); | ||
expandButton.innerText = 'Expand More Items'; | ||
expandButton.classList.add('expand-button'); | ||
|
||
// Insert the button at the top of the sidebar or before the '.sidebar-elems' | ||
var sidebarElems = document.querySelector('.sidebar-elems'); | ||
sidebarElems.parentNode.insertBefore(expandButton, sidebarElems); | ||
|
||
// Initially hide the '.sidebar-elems' | ||
sidebarElems.style.display = 'none'; | ||
|
||
// Add click event listener to the button | ||
expandButton.addEventListener('click', function() { | ||
// Toggle the display of the '.sidebar-elems' | ||
if (sidebarElems.style.display === 'none') { | ||
sidebarElems.style.display = 'block'; | ||
expandButton.innerText = 'Collapse'; | ||
} else { | ||
sidebarElems.style.display = 'none'; | ||
expandButton.innerText = 'Expand for More'; | ||
} | ||
}); | ||
} | ||
|
||
window.addEventListener("DOMContentLoaded", (event) => { | ||
// if the crate is one that starts with `polkadot_sdk_docs` | ||
let crate_name = document.querySelector("#main-content > div > h1 > a:nth-child(1)"); | ||
if (!crate_name.textContent.startsWith("polkadot_sdk_docs")) { | ||
console.log("skipping -- not `polkadot_sdk_docs`"); | ||
return; | ||
} | ||
|
||
createToC(); | ||
hideSidebarElements(); | ||
|
||
console.log("updating page based on being `polkadot_sdk_docs` crate"); | ||
}); | ||
</script> | ||
|
||
<style> | ||
|
||
nav.side-bar { | ||
width: 300px; | ||
} | ||
|
||
.sidebar-table-of-contents { | ||
margin-bottom: 1em; | ||
padding: 0.5em; | ||
} | ||
|
||
.sidebar-table-of-contents a { | ||
display: block; | ||
margin: 0.2em 0; | ||
} | ||
|
||
.sidebar-table-of-contents .h2 { | ||
font-weight: bold; | ||
margin-left: 0; | ||
} | ||
|
||
.sidebar-table-of-contents .h3 { | ||
margin-left: 1em; | ||
} | ||
|
||
.sidebar-table-of-contents .h4 { | ||
margin-left: 2em; | ||
} | ||
|
||
.sidebar h2.location { | ||
display: none; | ||
} | ||
|
||
.sidebar-elems { | ||
display: none; | ||
} | ||
|
||
/* Center the 'Expand for More' button */ | ||
.expand-button { | ||
display: inline-block; /* Use inline-block for sizing */ | ||
margin: 10px auto; /* Auto margins for horizontal centering */ | ||
padding: 5px 10px; | ||
background-color: #007bff; | ||
color: white; | ||
text-align: center; | ||
cursor: pointer; | ||
border: none; | ||
border-radius: 5px; | ||
width: auto; | ||
/* Centering the button within its parent container */ | ||
position: relative; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
} | ||
|
||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
:root { | ||
--polkadot-pink: #E6007A ; | ||
--polkadot-green: #56F39A ; | ||
--polkadot-lime: #D3FF33 ; | ||
--polkadot-cyan: #00B2FF ; | ||
--polkadot-purple: #552BBF ; | ||
} | ||
|
||
body > nav.sidebar > div.sidebar-crate > a > img { | ||
/* logo width, given that the sidebar width is 200px; */ | ||
width: 190px; | ||
} | ||
|
||
body nav.sidebar { | ||
flex: 0 0 250px; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.