mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Add comments to generated files
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||||
# `!admin appservices`
|
# `!admin appservices`
|
||||||
|
|
||||||
- Commands for managing appservices
|
- Commands for managing appservices
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||||
# `!admin check`
|
# `!admin check`
|
||||||
|
|
||||||
- Commands for checking integrity
|
- Commands for checking integrity
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||||
# `!admin debug`
|
# `!admin debug`
|
||||||
|
|
||||||
- Commands for debugging things
|
- Commands for debugging things
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||||
# `!admin federation`
|
# `!admin federation`
|
||||||
|
|
||||||
- Commands for managing federation
|
- Commands for managing federation
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||||
# Admin Commands
|
# Admin Commands
|
||||||
|
|
||||||
These are all the admin commands. TODO fill me out
|
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`
|
# `!admin media`
|
||||||
|
|
||||||
- Commands for managing media
|
- Commands for managing media
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||||
# `!admin query`
|
# `!admin query`
|
||||||
|
|
||||||
- Low-level queries for database getters and iterators
|
- 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`
|
# `!admin rooms`
|
||||||
|
|
||||||
- Commands for managing rooms
|
- Commands for managing rooms
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||||
# `!admin server`
|
# `!admin server`
|
||||||
|
|
||||||
- Commands for managing the server
|
- Commands for managing the server
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||||
# `!admin token`
|
# `!admin token`
|
||||||
|
|
||||||
- Commands for managing registration tokens
|
- Commands for managing registration tokens
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- This file is generated by `cargo xtask generate-docs`. Do not edit. -->
|
||||||
# `!admin users`
|
# `!admin users`
|
||||||
|
|
||||||
- Commands for managing local users
|
- Commands for managing local users
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
mod admin_commands;
|
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;
|
use cargo_metadata::MetadataCommand;
|
||||||
|
|
||||||
@@ -16,13 +16,33 @@ struct FileQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl 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<()> {
|
fn write(self, root: &Path, dry_run: bool) -> std::io::Result<()> {
|
||||||
for (path, contents) in self.queue {
|
for (path, contents) in self.queue {
|
||||||
let path = root.join(&path);
|
let path = root.join(&path);
|
||||||
|
|
||||||
eprintln!("Writing {}", path.display());
|
eprintln!("Writing {}", path.display());
|
||||||
if !dry_run {
|
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)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user