feat: Add comments to generated files
This commit is contained in:
parent
66fcedf08b
commit
7b159bc8c8
12 changed files with 33 additions and 2 deletions
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# `!admin appservices`
|
||||
|
||||
- Commands for managing appservices
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# `!admin check`
|
||||
|
||||
- Commands for checking integrity
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# `!admin debug`
|
||||
|
||||
- Commands for debugging things
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# `!admin federation`
|
||||
|
||||
- Commands for managing federation
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# Admin Commands
|
||||
|
||||
These are all the admin commands. TODO fill me out
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# `!admin media`
|
||||
|
||||
- Commands for managing media
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# `!admin query`
|
||||
|
||||
- Low-level queries for database getters and iterators
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# `!admin rooms`
|
||||
|
||||
- Commands for managing rooms
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# `!admin server`
|
||||
|
||||
- Commands for managing the server
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# `!admin token`
|
||||
|
||||
- Commands for managing registration tokens
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||
# `!admin users`
|
||||
|
||||
- Commands for managing local users
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
mod admin_commands;
|
||||
|
||||
use std::{collections::HashMap, path::{Path, PathBuf}};
|
||||
use std::{collections::HashMap, fs::File, io::Write, path::{Path, PathBuf}};
|
||||
|
||||
use cargo_metadata::MetadataCommand;
|
||||
|
||||
|
|
@ -16,13 +16,33 @@ struct FileQueue {
|
|||
}
|
||||
|
||||
impl FileQueue {
|
||||
const GENERATED_HEADER: &'static str = "This file is generated by `cargo xtask generate-docs`. Do not edit.";
|
||||
|
||||
/// Generate the header for the file at `path`.
|
||||
fn header_for(path: &Path) -> Option<String> {
|
||||
Some(match path.extension()?.as_encoded_bytes() {
|
||||
b"md" => format!("<!-- {} -->", Self::GENERATED_HEADER),
|
||||
_ => return None
|
||||
})
|
||||
}
|
||||
|
||||
/// Write all queued files into the file tree rooted at `root`.
|
||||
fn write(self, root: &Path, dry_run: bool) -> std::io::Result<()> {
|
||||
for (path, contents) in self.queue {
|
||||
let path = root.join(&path);
|
||||
|
||||
eprintln!("Writing {}", path.display());
|
||||
if !dry_run {
|
||||
std::fs::write(path, contents)?;
|
||||
let mut file = File::create(&path)?;
|
||||
|
||||
if let Some(header) = Self::header_for(&path) {
|
||||
writeln!(file, "{header}")?;
|
||||
}
|
||||
|
||||
write!(file, "{contents}")?;
|
||||
if !contents.ends_with('\n') {
|
||||
writeln!(file)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue