From d43b2094f925073e98b41354d3034556effc2091 Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Tue, 20 May 2025 18:08:41 +0300 Subject: [PATCH 1/5] Build doc without deps --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 61878e2..8c34a97 100644 --- a/Makefile +++ b/Makefile @@ -27,10 +27,10 @@ bench: xdg-open target/criterion/push\ and\ clear/report/index.html doc: - cargo doc --open + cargo doc --no-deps --open build-doc: - cargo doc + cargo doc --no-deps dev: echo Installing pre-commit hook... From 3b731855d7a397c1e2981e1ca723a1e3f7306aeb Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Tue, 20 May 2025 18:10:40 +0300 Subject: [PATCH 2/5] Build and deploy doc --- .github/workflows/ci.yml | 12 +++++++++++- README.md | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b98ce1e..781c6eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,10 +52,20 @@ jobs: doc: runs-on: ubuntu-latest + permissions: + contents: write steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - run: cargo doc + - run: cargo doc --no-deps + - run: | + echo '' > target/doc/index.html + - uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./target/doc + publish_branch: gh-pages + # if: github.ref == 'refs/heads/master' clippy: runs-on: ubuntu-latest diff --git a/README.md b/README.md index dac4ef6..c5c9a77 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![build](https://github.com/andreiavrammsd/static_vector.rs/workflows/CI/badge.svg)](https://github.com/andreiavrammsd/static_vector.rs/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/andreiavrammsd/static_vector.rs/graph/badge.svg?token=pCcpya0mZC)](https://codecov.io/gh/andreiavrammsd/static_vector.rs) +[![documentation](https://img.shields.io/badge/Documentation-static_vector-4EC820.svg)](https://andreiavrammsd.github.io/static_vector.rs/) A no-std, stack-allocated vector with fixed capacity and dynamic length. From 81a5e5ea93ab69a7f1c29497e8243a8fe061dfd6 Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Tue, 20 May 2025 18:58:28 +0300 Subject: [PATCH 3/5] Add doc alias --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 006024b..e49c452 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -79,6 +79,7 @@ impl Vec { /// /// Returns [`CapacityExceededError`] if the vector is already at full capacity. #[inline] + #[doc(alias = "add")] pub fn push(&mut self, value: &T) -> Result<(), CapacityExceededError> { if self.length == CAPACITY { return Err(CapacityExceededError); From e559a871bd2cad4f5b50565b2c7f420f84a52950 Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Tue, 20 May 2025 19:01:29 +0300 Subject: [PATCH 4/5] Add doc aliases --- src/lib.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index e49c452..5054b1e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,12 +57,14 @@ impl Vec { /// Returns the maximum number of elements the vector can contain. #[inline(always)] + #[doc(alias("max", "size", "limit", "length"))] pub fn capacity(&self) -> usize { CAPACITY } /// Returns the maximum number of elements the vector currenly contains. #[inline(always)] + #[doc(alias("length", "size"))] pub fn len(&self) -> usize { self.length } @@ -79,7 +81,7 @@ impl Vec { /// /// Returns [`CapacityExceededError`] if the vector is already at full capacity. #[inline] - #[doc(alias = "add")] + #[doc(alias("add", "append", "insert"))] pub fn push(&mut self, value: &T) -> Result<(), CapacityExceededError> { if self.length == CAPACITY { return Err(CapacityExceededError); @@ -93,6 +95,7 @@ impl Vec { /// Removes all elements. Size will be zero. #[inline] + #[doc(alias("reset", "remove", "truncate", "empty"))] pub fn clear(&mut self) { self.drop(0, self.length); self.length = 0 @@ -108,6 +111,7 @@ impl Vec { /// # Errors /// /// Returns [`LengthTooLargeError`] if `new_length` exceeds the vector's fixed capacity. + #[doc(alias("resize", "length"))] pub fn set_len(&mut self, new_length: usize) -> Result<(), LengthTooLargeError> where T: Default, @@ -131,6 +135,7 @@ impl Vec { /// Returns a reference to the first element in the vector, or [`None`] if the vector is empty. #[must_use] #[inline] + #[doc(alias("front", "head", "start"))] pub fn first(&self) -> Option<&T> { if self.length == 0 { None } else { Some(unsafe { &*self.data[0].as_ptr() }) } } @@ -138,6 +143,7 @@ impl Vec { /// Returns a reference to the last element in the vector, or [`None`] if the vector is empty. #[must_use] #[inline] + #[doc(alias("back", "tail", "end"))] pub fn last(&self) -> Option<&T> { if self.length == 0 { None } else { Some(unsafe { &*self.data[self.length - 1].as_ptr() }) } } @@ -145,6 +151,7 @@ impl Vec { /// Returns a reference to the element at the specified `index`, or [`None`] if out of bounds. #[must_use] #[inline] + #[doc(alias("at", "index"))] pub fn get(&self, index: usize) -> Option<&T> { if index >= self.length { None } else { Some(unsafe { &*self.data[index].as_ptr() }) } } @@ -152,6 +159,7 @@ impl Vec { /// Returns a mutable reference to the element at the specified `index`, or [`None`] if out of bounds. #[must_use] #[inline] + #[doc(alias("at", "index"))] pub fn get_mut(&mut self, index: usize) -> Option<&mut T> { if index >= self.length { None @@ -163,6 +171,7 @@ impl Vec { /// Returns (and removes) the last element from the vector, or [`None`] if the vector is empty. #[must_use] #[inline] + #[doc(alias("remove", "get"))] pub fn pop(&mut self) -> Option { if self.length == 0 { None @@ -176,6 +185,7 @@ impl Vec { /// or [`None`] if the vector is empty or the predicate returns false. #[must_use] #[inline] + #[doc(alias("remove", "get"))] pub fn pop_if(&mut self, predicate: impl FnOnce(&T) -> bool) -> Option { let last = self.last()?; if predicate(last) { self.pop() } else { None } From 8650cb468a33fbf51f6bcea329a420513c632226 Mon Sep 17 00:00:00 2001 From: Andrei Avram <6795248+andreiavrammsd@users.noreply.github.com> Date: Tue, 20 May 2025 19:36:03 +0300 Subject: [PATCH 5/5] Publish doc only on master --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 781c6eb..e137c50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,12 +60,13 @@ jobs: - run: cargo doc --no-deps - run: | echo '' > target/doc/index.html + if: github.ref == 'refs/heads/master' - uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./target/doc publish_branch: gh-pages - # if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' clippy: runs-on: ubuntu-latest