MCPcopy Create free account
hub / github.com/bevyengine/bevy-website / write_section

Function write_section

generate-errors/src/lib.rs:121–152  ·  view source on GitHub ↗

Writes a valid docs section to contain the error pages in. The output path passed should be the folder you want the Zola pages to be written / output.

(output_path: &Path)

Source from the content-addressed store, hash-verified

119/// The output path passed should be the folder
120/// you want the Zola pages to be written / output.
121pub fn write_section(output_path: &Path) -> anyhow::Result<()> {
122 let errors_folder_path = output_path.join("errors");
123 // Make sure the output folder exists
124 fs::create_dir_all(&errors_folder_path)?;
125
126 const SECTION_CONTENT: &str = r#"+++
127title = "Errors"
128template = "docs.html"
129page_template = "docs.html"
130redirect_to = "/learn/errors/introduction"
131+++
132"#;
133
134 const INTRODUCTION_CONTENT: &str = r#"+++
135title = "Introduction"
136[extra]
137weight = 0
138+++
139
140These pages document Bevy's error codes for the _current release_.
141
142In case you are looking for the latest error codes from Bevy's main branch, you can find them in the [Bevy engine repository](<https://github.com/bevyengine/bevy/tree/main/errors>).
143"#;
144
145 fs::write(errors_folder_path.join("_index.md"), SECTION_CONTENT)?;
146 fs::write(
147 errors_folder_path.join("introduction.md"),
148 INTRODUCTION_CONTENT,
149 )?;
150
151 Ok(())
152}
153
154pub fn write_pages(output_path: &Path, pages: HashMap<String, String>) -> anyhow::Result<()> {
155 let errors_folder_path = output_path.join("errors");

Callers 2

test_write_sectionFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_write_sectionFunction · 0.68