Skip to content

Commit e8604ac

Browse files
authored
Merge pull request #570 from myzhan/main
emmylua_doc_cli: support custom site_name
2 parents 5cffbb2 + 4461a76 commit e8604ac

6 files changed

Lines changed: 18 additions & 0 deletions

File tree

crates/emmylua_doc_cli/src/cmd_args.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ pub struct CmdArgs {
1919
#[arg(long)]
2020
pub override_template: Option<PathBuf>,
2121

22+
#[arg(long, default_value = "Docs")]
23+
pub site_name: Option<String>,
24+
2225
/// The path of the mixin md file
2326
#[arg(long)]
2427
pub mixin: Option<PathBuf>,

crates/emmylua_doc_cli/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3333
&mut analysis,
3434
args.output,
3535
args.override_template,
36+
args.site_name,
3637
args.mixin,
3738
),
3839
Format::Json => json_generator::generate_json(&mut analysis, args.output),

crates/emmylua_doc_cli/src/markdown_generator/gen/index_gen.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ pub fn generate_index(
1212
mkdocs.modules.sort_by(|a, b| a.name.cmp(&b.name));
1313
mkdocs.globals.sort_by(|a, b| a.name.cmp(&b.name));
1414

15+
if !mkdocs.site_name.is_empty() {
16+
context.insert("site_name", &mkdocs.site_name);
17+
}
1518
if !mkdocs.types.is_empty() {
1619
context.insert("types", &mkdocs.types);
1720
}

crates/emmylua_doc_cli/src/markdown_generator/markdown_types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct Property {
2828

2929
#[derive(Debug, Serialize, Deserialize, Default)]
3030
pub struct MkdocsIndex {
31+
pub site_name: String,
3132
pub types: Vec<IndexStruct>,
3233
pub modules: Vec<IndexStruct>,
3334
pub globals: Vec<IndexStruct>,

crates/emmylua_doc_cli/src/markdown_generator/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub fn generate_markdown(
1616
analysis: &mut EmmyLuaAnalysis,
1717
output: PathBuf,
1818
override_template: Option<PathBuf>,
19+
site_name: Option<String>,
1920
mixin: Option<PathBuf>,
2021
) -> Result<(), Box<dyn std::error::Error>> {
2122
let docs_dir = output.join("docs");
@@ -51,6 +52,10 @@ pub fn generate_markdown(
5152

5253
let tl = init_tl::init_tl(override_template).ok_or("Failed to initialize TL")?;
5354
let mut mkdocs_index = MkdocsIndex::default();
55+
if let Some(site_name) = site_name {
56+
mkdocs_index.site_name = site_name;
57+
}
58+
5459
let db = analysis.compilation.get_db();
5560
let type_index = db.get_type_index();
5661
let types = type_index.get_all_types();

crates/emmylua_doc_cli/template/mkdocs_template.tl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
{% if site_name %}
2+
site_name: {{ site_name }}
3+
{% else %}
14
site_name: Docs
5+
{% endif %}
6+
27
theme:
38
name: material
49
font:

0 commit comments

Comments
 (0)