typenotion
is a CLI tool for generating Rust types from data stored in Notion sites.Not affiliated with Notion!
For example, given the following Notion database:
Running the command:
typenotion enum <DATABASE_ID> --generate-docs --generate-display --derive=Copy --derive=Clone
will generate a file named player_variants.rs
with the following source code:
// Generated at 2024-04-08T22:36:31.574003+00:00
#[derive(Copy, Clone)]
enum PlayerVariants {
/// ## Player with Full Upgrades
///
/// This is the variant applied to the player when they’re fully upgraded.
///
/// This variant overrides all other variants (i.e. even if they have a weapon equipped, this variant will take precedence).
///
/// [Link to Notion record](https://www.notion.so/Player-with-Full-Upgrades-0123...)
PlayerWithFullUpgrades,
/// ## Player with Tool
///
/// This is the variant applied to the player when they’re wielding a tool.
///
/// [Link to Notion record](https://www.notion.so/Player-with-Tool-0123...)
PlayerWithTool,
/// ## Default Player
///
/// This is the default player variant (considered “base” or “standard”). They have no tools, weapons, or upgrades.
///
/// [Link to Notion record](https://www.notion.so/Default-Player-0123...)
DefaultPlayer,
/// ## Player with Weapon
///
/// This is the variant applied to the player when they’re currently holding a weapon.
///
/// [Link to Notion record](https://www.notion.so/Player-with-Weapon-0123...)
PlayerWithWeapon,
}
impl std::fmt::Display for PlayerVariants {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
use PlayerVariants::*;
match self {
PlayerWithFullUpgrades => write!(f, "Player with Full Upgrades"),
PlayerWithTool => write!(f, "Player with Tool"),
DefaultPlayer => write!(f, "Default Player"),
PlayerWithWeapon => write!(f, "Player with Weapon"),
}
}
}
typenotion is free and open source. Unless explicitly noted otherwise, all code in this repository is dual-licensed under the MIT License and Apache License, Version 2.0.
This licensing approach is the de facto standard within the Rust ecosystem.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.