From 9dbfa445aba083bcdcd4fd654dd9cbc5d9ea79dd Mon Sep 17 00:00:00 2001 From: mattwparas Date: Fri, 22 Dec 2023 14:44:31 -0800 Subject: [PATCH] clean up hash doc --- crates/steel-core/src/primitives/hashmaps.rs | 37 +++++++++++--------- docs/src/builtins/#%private_steel_mhash.md | 4 +++ docs/src/builtins/#%private_steel_mvector.md | 10 ++++++ docs/src/builtins/#%private_steel_reader.md | 5 +++ docs/src/builtins/steel_base.md | 20 +++++++++++ docs/src/builtins/steel_core/filesystem.md | 1 - docs/src/builtins/steel_core/result.md | 1 - docs/src/builtins/steel_core/types.md | 1 - docs/src/builtins/steel_hash.hd | 1 - docs/src/builtins/steel_hash.md | 20 +++++++++++ docs/src/builtins/steel_pords.md | 1 - 11 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 docs/src/builtins/#%private_steel_mhash.md create mode 100644 docs/src/builtins/#%private_steel_mvector.md create mode 100644 docs/src/builtins/#%private_steel_reader.md delete mode 100644 docs/src/builtins/steel_core/filesystem.md delete mode 100644 docs/src/builtins/steel_core/result.md delete mode 100644 docs/src/builtins/steel_core/types.md delete mode 100644 docs/src/builtins/steel_hash.hd delete mode 100644 docs/src/builtins/steel_pords.md diff --git a/crates/steel-core/src/primitives/hashmaps.rs b/crates/steel-core/src/primitives/hashmaps.rs index 0bc4136f3..0e60fa2f6 100644 --- a/crates/steel-core/src/primitives/hashmaps.rs +++ b/crates/steel-core/src/primitives/hashmaps.rs @@ -25,7 +25,7 @@ declare_const_ref_functions!( pub(crate) fn hashmap_module() -> BuiltInModule { let mut module = BuiltInModule::new("steel/hash".to_string()); module - .register_value_with_doc("hash", HM_CONSTRUCT, HASH_DOC) + .register_native_fn_definition(HM_CONSTRUCT_DEFINITION) .register_value("%keyword-hash", SteelVal::FuncV(hm_construct_keywords)) .register_native_fn_definition(HASH_INSERT_DEFINITION) .register_native_fn_definition(HASH_REF_DEFINITION) @@ -47,21 +47,26 @@ pub(crate) fn hashmap_module() -> BuiltInModule { module } -const HASH_DOC: DocTemplate<'static> = DocTemplate { - signature: "(hash key val ...) -> hash?", - params: &["key : hashable?", "val : any/c"], - description: r#"Creates an immutable hash table with each given `key` mapped to the following `val`; each key must have a val, so the total number of arguments must be even. - -Note, the key must be hashable."#, - examples: &[( - "> (hash 'a 10 'b 20)", - r#"=> #"#, - )], -}; - +/// Creates an immutable hash table with each given `key` mapped to the following `val`. +/// Each key must have a val, so the total number of arguments must be even. +/// +/// +/// (hash key val ...) -> hash? +/// +/// key : hashable? +/// val : any/c +/// +/// Note: the keys must be hashable. +/// +/// # Examples +/// ```scheme +/// > (hash 'a 10 'b 20)", +/// r#"=> #"#, +/// ``` +#[steel_derive::native(name = "hash", arity = "AtLeast(0)")] pub fn hm_construct(args: &[SteelVal]) -> Result { let mut hm = HashMap::new(); diff --git a/docs/src/builtins/#%private_steel_mhash.md b/docs/src/builtins/#%private_steel_mhash.md new file mode 100644 index 000000000..ef9f330dd --- /dev/null +++ b/docs/src/builtins/#%private_steel_mhash.md @@ -0,0 +1,4 @@ +# #%private/steel/mhash +### **mhash** +### **mhash-ref** +### **mhash-set!** diff --git a/docs/src/builtins/#%private_steel_mvector.md b/docs/src/builtins/#%private_steel_mvector.md new file mode 100644 index 000000000..9fa4e70a8 --- /dev/null +++ b/docs/src/builtins/#%private_steel_mvector.md @@ -0,0 +1,10 @@ +# #%private/steel/mvector +### **make-mutable-vector** +### **mutable-vector->list** +### **mutable-vector-empty?** +### **mutable-vector-from-list** +### **mutable-vector-len** +### **mutable-vector-pop!** +### **mutable-vector-push!** +### **mutable-vector-ref** +### **mutable-vector-set!** diff --git a/docs/src/builtins/#%private_steel_reader.md b/docs/src/builtins/#%private_steel_reader.md new file mode 100644 index 000000000..6008ffb2c --- /dev/null +++ b/docs/src/builtins/#%private_steel_reader.md @@ -0,0 +1,5 @@ +# #%private/steel/reader +### **new-reader** +### **reader-empty?** +### **reader-push-string** +### **reader-read-one** diff --git a/docs/src/builtins/steel_base.md b/docs/src/builtins/steel_base.md index 527622d69..32c57eebd 100644 --- a/docs/src/builtins/steel_base.md +++ b/docs/src/builtins/steel_base.md @@ -71,6 +71,26 @@ Returns the first element of the list l. > (first '(1 2)) ;; => 1 > (first (cons 2 3)) ;; => 2 ``` +### **hash** +Creates an immutable hash table with each given `key` mapped to the following `val`. +Each key must have a val, so the total number of arguments must be even. + + +(hash key val ...) -> hash? + +key : hashable? +val : any/c + +Note: the keys must be hashable. + +#### Examples +```scheme +> (hash 'a 10 'b 20)", +r#"=> #"#, +``` ### **hash-contains?** Checks whether the given map contains the given key. Key must be hashable. diff --git a/docs/src/builtins/steel_core/filesystem.md b/docs/src/builtins/steel_core/filesystem.md deleted file mode 100644 index e1f73b547..000000000 --- a/docs/src/builtins/steel_core/filesystem.md +++ /dev/null @@ -1 +0,0 @@ -# steel/filesystem diff --git a/docs/src/builtins/steel_core/result.md b/docs/src/builtins/steel_core/result.md deleted file mode 100644 index 700f8590b..000000000 --- a/docs/src/builtins/steel_core/result.md +++ /dev/null @@ -1 +0,0 @@ -# steel/core/result diff --git a/docs/src/builtins/steel_core/types.md b/docs/src/builtins/steel_core/types.md deleted file mode 100644 index 7544bff37..000000000 --- a/docs/src/builtins/steel_core/types.md +++ /dev/null @@ -1 +0,0 @@ -# steel/core/types diff --git a/docs/src/builtins/steel_hash.hd b/docs/src/builtins/steel_hash.hd deleted file mode 100644 index 6a824affa..000000000 --- a/docs/src/builtins/steel_hash.hd +++ /dev/null @@ -1 +0,0 @@ -# steel/hash diff --git a/docs/src/builtins/steel_hash.md b/docs/src/builtins/steel_hash.md index c1c34b9da..9c90de365 100644 --- a/docs/src/builtins/steel_hash.md +++ b/docs/src/builtins/steel_hash.md @@ -1,4 +1,24 @@ # steel/hash +### **hash** +Creates an immutable hash table with each given `key` mapped to the following `val`. +Each key must have a val, so the total number of arguments must be even. + + +(hash key val ...) -> hash? + +key : hashable? +val : any/c + +Note: the keys must be hashable. + +#### Examples +```scheme +> (hash 'a 10 'b 20)", +r#"=> #"#, +``` ### **hash-contains?** Checks whether the given map contains the given key. Key must be hashable. diff --git a/docs/src/builtins/steel_pords.md b/docs/src/builtins/steel_pords.md deleted file mode 100644 index 20ee7e5d8..000000000 --- a/docs/src/builtins/steel_pords.md +++ /dev/null @@ -1 +0,0 @@ -# steel/ports