From 0f6f6f99e3197bee62b63c8c9cd010acf1e1d797 Mon Sep 17 00:00:00 2001 From: Chad Baker Date: Tue, 21 May 2024 11:56:46 -0600 Subject: [PATCH 1/2] working through docs in history fields --- README.md | 2 +- .../src/history_vec_derive.rs | 17 +++++++++++++++++ rust/altrios-core/src/track/link/link_impl.rs | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f5c9b49d..8efe5aea 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ If you are an ALTRIOS developer, see [Developer Documentation](https://nrel.gith - Option 2 -- Anaconda: we recommend https://docs.conda.io/en/latest/miniconda.html. 1. Setup a python environment. ALTRIOS can work with Python 3.9, or 3.10, but we recommend 3.10 for better performance and user experience. Create a python environment for ALTRIOS with either of two methods: - Option 1 -- [Python Venv](https://docs.python.org/3/library/venv.html) - 1. Navigate to the ALTRIOS folder you just cloned or any folder you'd like for using ALTRIOS. Remember the folder you use! + 1. Navigate to your project folder in which you'd like to store model data and run ALTRIOS. 1. Assuming you have Python 3.10 installed, run `python3.10 -m venv altrios-venv` in your terminal enviroment (we recommend PowerShell in Windows, which comes pre-installed). This tells Python 3.10 to use the `venv` module to create a virtual environment (which will be ignored by git if named `altrios-venv`) in the `ALTRIOS/altrios-venv/`. 1. Activate the environment you just created to install packages or anytime you're running ALTRIOS: - Mac and Linux: `source altrios-venv/bin/activate` diff --git a/rust/altrios-core/altrios-proc-macros/src/history_vec_derive.rs b/rust/altrios-core/altrios-proc-macros/src/history_vec_derive.rs index e5108525..9f2e3f3c 100644 --- a/rust/altrios-core/altrios-proc-macros/src/history_vec_derive.rs +++ b/rust/altrios-core/altrios-proc-macros/src/history_vec_derive.rs @@ -21,6 +21,23 @@ pub(crate) fn history_vec_derive(input: TokenStream) -> TokenStream { .map(|f| { let ident = f.ident.as_ref().unwrap(); let ty = &f.ty; + let doc_attrs = &f + .attrs + .iter() + .filter(|attr| { + if attr.path.is_ident("doc") { + attr.parse_meta().is_ok_and(|meta| { + if let syn::Meta::NameValue(_) = meta { + true + } else { + false + } + }) + } else { + false + } + }) + .collect::>(); quote! { pub #ident: Vec<#ty>, } diff --git a/rust/altrios-core/src/track/link/link_impl.rs b/rust/altrios-core/src/track/link/link_impl.rs index c555bbec..c95ab7a4 100644 --- a/rust/altrios-core/src/track/link/link_impl.rs +++ b/rust/altrios-core/src/track/link/link_impl.rs @@ -15,7 +15,7 @@ struct OldSpeedSets(Vec); pub struct Link { /// Index of current link pub idx_curr: LinkIdx, - /// Index of adjacent link in reverse direction + /// Index of current link in reverse direction pub idx_flip: LinkIdx, /// see [EstTime::idx_next] pub idx_next: LinkIdx, From ab6157c1954afcfa2ac8c216de8892d4adc664a8 Mon Sep 17 00:00:00 2001 From: Chad Baker Date: Tue, 21 May 2024 12:07:14 -0600 Subject: [PATCH 2/2] all `history` fields now get docs from `state` --- .../altrios-proc-macros/src/history_vec_derive.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/rust/altrios-core/altrios-proc-macros/src/history_vec_derive.rs b/rust/altrios-core/altrios-proc-macros/src/history_vec_derive.rs index 9f2e3f3c..61818f9f 100644 --- a/rust/altrios-core/altrios-proc-macros/src/history_vec_derive.rs +++ b/rust/altrios-core/altrios-proc-macros/src/history_vec_derive.rs @@ -26,19 +26,15 @@ pub(crate) fn history_vec_derive(input: TokenStream) -> TokenStream { .iter() .filter(|attr| { if attr.path.is_ident("doc") { - attr.parse_meta().is_ok_and(|meta| { - if let syn::Meta::NameValue(_) = meta { - true - } else { - false - } - }) + attr.parse_meta() + .is_ok_and(|meta| matches!(meta, syn::Meta::NameValue(_))) } else { false } }) .collect::>(); quote! { + #(#doc_attrs)* pub #ident: Vec<#ty>, } })