Skip to content

Commit

Permalink
Add book.toml generation
Browse files Browse the repository at this point in the history
commit-id:b5f6227b
  • Loading branch information
piotmag769 committed Jul 18, 2024
1 parent 6ed17ae commit 9241698
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion extensions/scarb-doc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cairo-lang-starknet.workspace = true
cairo-lang-syntax.workspace = true
cairo-lang-utils.workspace = true
expect-test.workspace = true
indoc.workspace = true
itertools.workspace = true
scarb-metadata = { path = "../../scarb-metadata" }
scarb-ui = { path = "../../utils/scarb-ui" }
Expand All @@ -32,5 +33,4 @@ smol_str.workspace = true

[dev-dependencies]
assert_fs.workspace = true
indoc.workspace = true
scarb-test-support = { path = "../../utils/scarb-test-support" }
1 change: 1 addition & 0 deletions extensions/scarb-doc/src/docs_generation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod markdown;
1 change: 1 addition & 0 deletions extensions/scarb-doc/src/docs_generation/markdown.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mod book_toml;
29 changes: 29 additions & 0 deletions extensions/scarb-doc/src/docs_generation/markdown/book_toml.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use indoc::formatdoc;

use crate::AdditionalMetadata;

#[allow(dead_code)]
pub fn generate_book_toml_content(package_metadata: &AdditionalMetadata) -> String {
formatdoc! {
r#"
[book]
authors = {:?}
language = "en"
multilingual = false
src = "src"
title = "{} - Cairo"
[output.html]
no-section-label = true
[output.html.playground]
runnable = false
[output.html.fold]
enable = true
level = 0
"#,
package_metadata.authors.clone().unwrap_or_else(|| vec!["<unknown>".to_string()]),
package_metadata.name
}
}
1 change: 1 addition & 0 deletions extensions/scarb-doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::metadata::compilation::get_project_config;
use types::Crate;

pub mod db;
pub mod docs_generation;
pub mod metadata;
pub mod types;
pub mod versioned_json_output;
Expand Down

0 comments on commit 9241698

Please sign in to comment.