fix: set clarity version when building boot contracts' docs

This commit is contained in:
Brice Dobry
2024-05-05 20:04:20 -04:00
parent 2a63b46290
commit 7763df2782
3 changed files with 16 additions and 7 deletions

View File

@@ -95,10 +95,13 @@ fn doc_execute(program: &str) -> Result<Option<Value>, vm::Error> {
}
#[allow(clippy::expect_used)]
pub fn make_docs(content: &str, support_docs: &ContractSupportDocs) -> ContractRef {
let (_, contract_analysis) =
mem_type_check(content, ClarityVersion::latest(), StacksEpochId::latest())
.expect("BUG: failed to type check boot contract");
pub fn make_docs(
content: &str,
support_docs: &ContractSupportDocs,
version: ClarityVersion,
) -> ContractRef {
let (_, contract_analysis) = mem_type_check(content, version, StacksEpochId::latest())
.expect("BUG: failed to type check boot contract");
let ContractAnalysis {
public_function_types,
@@ -179,12 +182,13 @@ pub fn make_docs(content: &str, support_docs: &ContractSupportDocs) -> ContractR
pub fn produce_docs_refs<A: AsRef<str>, B: AsRef<str>>(
contracts: &[(A, B)],
support_docs: &HashMap<&str, ContractSupportDocs>,
version: ClarityVersion,
) -> BTreeMap<String, ContractRef> {
let mut docs = BTreeMap::new();
for (contract_name, content) in contracts.iter() {
if let Some(contract_support) = support_docs.get(contract_name.as_ref()) {
let contract_ref = make_docs(content.as_ref(), contract_support);
let contract_ref = make_docs(content.as_ref(), contract_support, version);
docs.insert(contract_name.as_ref().to_string(), contract_ref);
}

View File

@@ -1,4 +1,5 @@
use clarity::vm::docs::contracts::{produce_docs_refs, ContractSupportDocs};
use clarity::vm::ClarityVersion;
use hashbrown::{HashMap, HashSet};
use super::STACKS_BOOT_CODE_MAINNET;
@@ -139,7 +140,11 @@ If your name is in a namespace where names do not expire, then you never need to
pub fn make_json_boot_contracts_reference() -> String {
let contract_supporting_docs = make_contract_support_docs();
let api_out = produce_docs_refs(&*STACKS_BOOT_CODE_MAINNET, &contract_supporting_docs);
let api_out = produce_docs_refs(
&*STACKS_BOOT_CODE_MAINNET,
&contract_supporting_docs,
ClarityVersion::Clarity1,
);
format!(
"{}",
serde_json::to_string(&api_out).expect("Failed to serialize documentation")

View File

@@ -119,7 +119,7 @@ lazy_static! {
format!("{}\n{}", BOOT_CODE_POX_MAINNET_CONSTS, POX_3_BODY);
pub static ref POX_3_TESTNET_CODE: String =
format!("{}\n{}", BOOT_CODE_POX_TESTNET_CONSTS, POX_3_BODY);
pub static ref POX_4_CODE: String = format!("{}", POX_4_BODY);
pub static ref POX_4_CODE: String = POX_4_BODY.to_string();
pub static ref BOOT_CODE_COST_VOTING_TESTNET: String = make_testnet_cost_voting();
pub static ref STACKS_BOOT_CODE_MAINNET: [(&'static str, &'static str); 6] = [
("pox", &BOOT_CODE_POX_MAINNET),