From ecf8abbe4a36c280e3d683f91cc1929c844b4797 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Sun, 21 Jul 2024 16:54:11 -0500 Subject: [PATCH] Significant work on docs --- .gitattributes | 2 ++ .gitignore | 10 +++++++--- cplusplus/README.rst | 4 ++++ docs/c/bcd.rst | 14 +++++++------- docs/c/factors.rst | 4 ++-- docs/c/fibonacci.rst | 4 ++-- docs/c/iterator.rst | 22 ++++++++++++++++++---- docs/c/p0001.rst | 12 ++++++++++++ docs/c/p0002.rst | 12 ++++++++++++ docs/c/p0003.rst | 12 ++++++++++++ docs/c/p0004.rst | 12 ++++++++++++ docs/c/p0005.rst | 12 ++++++++++++ docs/c/p0006.rst | 12 ++++++++++++ docs/c/p0007.rst | 12 ++++++++++++ docs/c/p0008.rst | 12 ++++++++++++ docs/c/p0009.rst | 12 ++++++++++++ docs/c/p0010.rst | 12 ++++++++++++ docs/c/p0011.rst | 12 ++++++++++++ docs/c/p0012.rst | 16 ++++++++++++++-- docs/c/p0013.rst | 12 ++++++++++++ docs/c/p0014.rst | 12 ++++++++++++ docs/c/p0015.rst | 12 ++++++++++++ docs/c/p0016.rst | 12 ++++++++++++ docs/c/p0034.rst | 12 ++++++++++++ docs/c/p0076.rst | 12 ++++++++++++ docs/c/primes.rst | 4 ++-- docs/index.rst | 6 +++--- 27 files changed, 265 insertions(+), 25 deletions(-) diff --git a/.gitattributes b/.gitattributes index 87604cdc..6a8c6930 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,4 @@ c/*.c linguist-language=c c/*.h linguist-language=c +cplusplus/*.cpp linguist-language=c++ +cplusplus/*.h linguist-language=c++ diff --git a/.gitignore b/.gitignore index f3abeb7d..b56f10d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,17 @@ **.pyc +__pycache__/** +**/__pycache__/** **/.pytest_cache/** **/.mypy_cache/** -javascript/node_modules/** +.pytest_cache/** +.mypy_cache/** +**/node_modules/** .vscode/** **log*.txt **/a.out **/*.exe **/build/** -venv/** +**/venv/** **.dll **.pdb csharp/*/obj @@ -17,4 +21,4 @@ docs/_build rust/target **/.coverage **/.coverage.* -javascript/coverage +**/coverage diff --git a/cplusplus/README.rst b/cplusplus/README.rst index d4e841e2..33bb39aa 100644 --- a/cplusplus/README.rst +++ b/cplusplus/README.rst @@ -55,6 +55,10 @@ around that. This test checks that those macros are correct. Prime Infrastructure Test ~~~~~~~~~~~~~~~~~~~~~~~~~ +(Note that this is in progress, and these tests will be run only when +there is an implementation to refer to. Since they are identical to the +test in the c folder, the test is already written and ready to go.) + This test checks five things: 1. It checks ``is_prime()`` for numbers up to ``MAX_PRIME``, where that diff --git a/docs/c/bcd.rst b/docs/c/bcd.rst index 616faed7..d0bfecff 100644 --- a/docs/c/bcd.rst +++ b/docs/c/bcd.rst @@ -34,18 +34,18 @@ It was also a good exercise in x86 assembly, as several portions are accellerate Shortcut value to determine if the encoded integer is 0. - .. c:function:: void free_BCD_int(BCD_int x) +.. c:function:: void free_BCD_int(BCD_int x) - .. c:function:: BCD_int new_BCD_int(uintmax_t a, bool negative) +.. c:function:: BCD_int new_BCD_int(uintmax_t a, bool negative) - .. c:function:: BCD_int BCD_from_bytes(const unsigned char *str, size_t chars, bool negative, bool little_endian) +.. c:function:: BCD_int BCD_from_bytes(const unsigned char *str, size_t chars, bool negative, bool little_endian) - Takes in an arbitrary-sized encoded integer (like in Python's :external:py:meth:`int.from_bytes`) to a - :c:type:`BCD_int`. + Takes in an arbitrary-sized encoded integer (like in Python's :external:py:meth:`int.from_bytes`) to a + :c:type:`BCD_int`. - .. c:function:: BCD_int BCD_from_ascii(const char *str, size_t digits, bool negative) +.. c:function:: BCD_int BCD_from_ascii(const char *str, size_t digits, bool negative) - From an ASCII-encoded integer to a :c:ref:`BCD_int`. + From an ASCII-encoded integer to a :c:ref:`BCD_int`. .. c:function:: BCD_int add_bcd(BCD_int x, BCD_int y) diff --git a/docs/c/factors.rst b/docs/c/factors.rst index b73e4c19..954ff3e6 100644 --- a/docs/c/factors.rst +++ b/docs/c/factors.rst @@ -23,8 +23,8 @@ factors for a given number. It is generally used by first calling .. c:function:: uintmax_t advance_factor_counter(factor_counter *fc) - .. c:function:: factor_counter proper_divisors(uintmax_t target) +.. c:function:: factor_counter proper_divisors(uintmax_t target) - .. c:function:: uintmax_t proper_divisor_count(uintmax_t target) +.. c:function:: uintmax_t proper_divisor_count(uintmax_t target) .. c:namespace-pop:: diff --git a/docs/c/fibonacci.rst b/docs/c/fibonacci.rst index 4eee4246..0238612f 100644 --- a/docs/c/fibonacci.rst +++ b/docs/c/fibonacci.rst @@ -31,8 +31,8 @@ fibonacci.h This represents the largest number the iterator is allowed to yield. - .. c:function:: fibonacci fibonacci1(uintmax_t limit) +.. c:function:: fibonacci fibonacci1(uintmax_t limit) - .. c:function:: fibonacci fibonacci0() +.. c:function:: fibonacci fibonacci0() .. c:namespace-pop:: diff --git a/docs/c/iterator.rst b/docs/c/iterator.rst index e0fbc808..bb9e3e77 100644 --- a/docs/c/iterator.rst +++ b/docs/c/iterator.rst @@ -64,24 +64,38 @@ iterator.h .. c:member:: uintmax_t (*iterator_function)(counter *it) + The function to advance the iterator and return the next element. + .. c:member:: bool exhausted : 1 + An indicator that tells you if the iterator is exhausted. + .. c:member:: bool started : 1 + An indicator that tells you if the interator has moved at all. + .. c:member:: bool phase : 1 + An indicator that flips every time the iterator moves. + .. c:member:: uintmax_t idx + The current position of the counter. + .. c:member:: uintmax_t stop + The point before which the counter will stop (as in :external:py:ref:`range`). + .. c:member:: intmax_t step - .. c:function:: uintmax_t iterate_counter(counter *i) + The amount by which the counter will move in each iteration (as in :external:py:ref:`range`). + +.. c:function:: uintmax_t iterate_counter(counter *i) - .. c:function:: counter counter3(uintmax_t start, uintmax_t stop, intmax_t step) +.. c:function:: counter counter3(uintmax_t start, uintmax_t stop, intmax_t step) - .. c:function:: counter counter2(uintmax_t start, uintmax_t stop) +.. c:function:: counter counter2(uintmax_t start, uintmax_t stop) - .. c:function:: counter counter1(uintmax_t stop) +.. c:function:: counter counter1(uintmax_t stop) .. c:namespace-pop:: diff --git a/docs/c/p0001.rst b/docs/c/p0001.rst index bfe7bf3d..0b9f4325 100644 --- a/docs/c/p0001.rst +++ b/docs/c/p0001.rst @@ -8,6 +8,18 @@ Includes - `iterator.h <./iterator.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0001() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0001.c :language: C :linenos: diff --git a/docs/c/p0002.rst b/docs/c/p0002.rst index 2fe3bea2..4b310d1b 100644 --- a/docs/c/p0002.rst +++ b/docs/c/p0002.rst @@ -8,6 +8,18 @@ Includes - `fibonacci.h <./fibonacci.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0002() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0002.c :language: C :linenos: diff --git a/docs/c/p0003.rst b/docs/c/p0003.rst index 8a1f68a1..1f580065 100644 --- a/docs/c/p0003.rst +++ b/docs/c/p0003.rst @@ -8,6 +8,18 @@ Includes - `primes.h <./primes.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0003() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0003.c :language: C :linenos: diff --git a/docs/c/p0004.rst b/docs/c/p0004.rst index e9864353..0da11cb0 100644 --- a/docs/c/p0004.rst +++ b/docs/c/p0004.rst @@ -8,6 +8,18 @@ Includes - `iterator.h <./digits.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0004() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0004.c :language: C :linenos: diff --git a/docs/c/p0005.rst b/docs/c/p0005.rst index 969b7851..3c6d5b2a 100644 --- a/docs/c/p0005.rst +++ b/docs/c/p0005.rst @@ -9,6 +9,18 @@ Includes - `macros.h <./macros.html>`__ - `primes.h <./primes.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0005() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0005.c :language: C :linenos: diff --git a/docs/c/p0006.rst b/docs/c/p0006.rst index fcb11a11..183c7112 100644 --- a/docs/c/p0006.rst +++ b/docs/c/p0006.rst @@ -3,6 +3,18 @@ C Implementation of Problem 6 View source code `here on GitHub! `_ +Solution +-------- + +.. c:func:: unsigned long long p0006() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0006.c :language: C :linenos: diff --git a/docs/c/p0007.rst b/docs/c/p0007.rst index 55c58c2a..1c603b4f 100644 --- a/docs/c/p0007.rst +++ b/docs/c/p0007.rst @@ -8,6 +8,18 @@ Includes - `primes.h <./primes.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0007() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0007.c :language: C :linenos: diff --git a/docs/c/p0008.rst b/docs/c/p0008.rst index 568ae808..04dca0ed 100644 --- a/docs/c/p0008.rst +++ b/docs/c/p0008.rst @@ -8,6 +8,18 @@ Includes - `macros.h <./macros.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0008() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0008.c :language: C :linenos: diff --git a/docs/c/p0009.rst b/docs/c/p0009.rst index 151d2593..c676028f 100644 --- a/docs/c/p0009.rst +++ b/docs/c/p0009.rst @@ -3,6 +3,18 @@ C Implementation of Problem 9 View source code `here on GitHub! `_ +Solution +-------- + +.. c:func:: unsigned long long p0009() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0009.c :language: C :linenos: diff --git a/docs/c/p0010.rst b/docs/c/p0010.rst index c9fcf096..beaf8c57 100644 --- a/docs/c/p0010.rst +++ b/docs/c/p0010.rst @@ -8,6 +8,18 @@ Includes - `primes.h <./primes.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0010() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0010.c :language: C :linenos: diff --git a/docs/c/p0011.rst b/docs/c/p0011.rst index 365c0452..c6d948c9 100644 --- a/docs/c/p0011.rst +++ b/docs/c/p0011.rst @@ -8,6 +8,18 @@ Includes - `macros.h <./macros.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0011() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0011.c :language: C :linenos: diff --git a/docs/c/p0012.rst b/docs/c/p0012.rst index 53b45c0c..4046918c 100644 --- a/docs/c/p0012.rst +++ b/docs/c/p0012.rst @@ -3,14 +3,26 @@ C Implementation of Problem 12 (port in progress) View source code `here on GitHub! `_ +.. note:: + + The port of this problem is still in progress + Includes -------- - `macros.h <./macros.html>`__ -.. note:: +Solution +-------- - The port of this problem is still in progress +.. c:func:: unsigned long long p0012() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. .. literalinclude:: ../../c/p0012.c :language: C diff --git a/docs/c/p0013.rst b/docs/c/p0013.rst index 43500d48..d2070d77 100644 --- a/docs/c/p0013.rst +++ b/docs/c/p0013.rst @@ -8,6 +8,18 @@ Includes - `bcd.h <./bcd.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0013() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0013.c :language: C :linenos: diff --git a/docs/c/p0014.rst b/docs/c/p0014.rst index 1cf1c445..e520305c 100644 --- a/docs/c/p0014.rst +++ b/docs/c/p0014.rst @@ -8,6 +8,18 @@ Includes - `macros.h <./macros.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0014() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0014.c :language: C :linenos: diff --git a/docs/c/p0015.rst b/docs/c/p0015.rst index be0dc53f..9db58669 100644 --- a/docs/c/p0015.rst +++ b/docs/c/p0015.rst @@ -8,6 +8,18 @@ Includes - `math.h <./math.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0015() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0015.c :language: C :linenos: diff --git a/docs/c/p0016.rst b/docs/c/p0016.rst index b91e6a04..cd2d360a 100644 --- a/docs/c/p0016.rst +++ b/docs/c/p0016.rst @@ -8,6 +8,18 @@ Includes - `bcd.h <./bcd.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0016() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0016.c :language: C :linenos: diff --git a/docs/c/p0034.rst b/docs/c/p0034.rst index fd9fd538..3eef77b7 100644 --- a/docs/c/p0034.rst +++ b/docs/c/p0034.rst @@ -9,6 +9,18 @@ Includes - `digits.h <./digits.html>`__ - `math.h <./math.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0034() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0034.c :language: C :linenos: diff --git a/docs/c/p0076.rst b/docs/c/p0076.rst index 8a8dc7ea..c052acfc 100644 --- a/docs/c/p0076.rst +++ b/docs/c/p0076.rst @@ -8,6 +8,18 @@ Includes - `macros.h <./macros.html>`__ +Solution +-------- + +.. c:func:: unsigned long long p0076() + +.. c:func:: int main(int argc, char const *argv[]) + + .. note:: + + This function is only present in the Python test runner, or when compiling as a standalone program. + It is not present when compiling for the Unity test runner. + .. literalinclude:: ../../c/p0076.c :language: C :linenos: diff --git a/docs/c/primes.rst b/docs/c/primes.rst index 24342f73..7cc5d5c5 100644 --- a/docs/c/primes.rst +++ b/docs/c/primes.rst @@ -120,9 +120,9 @@ primes.h The source of new prime numbers - .. c:function:: prime_factor_counter prime_factors(uintmax_t n) +.. c:function:: prime_factor_counter prime_factors(uintmax_t n) - .. c:macro:: free_prime_factor_counter(pfc) +.. c:macro:: free_prime_factor_counter(pfc) .. c:function:: uintmax_t is_composite(uintmax_t n) diff --git a/docs/index.rst b/docs/index.rst index 9052327d..9d6ad0d9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -93,9 +93,9 @@ This project is divided into several Makefiles, connected by a root Makefile whi +===========+======+======+======+======+======+======+ |Coverage | |d| | |ip| | |d| | |d| | |d| | |d| | +-----------+------+------+------+------+------+------+ -|Docs | |ip| | |ip| | |d| | |d| | |d| | |d| | +|Docs | |d| | |d| | |d| | |d| | |d| | |d| | +-----------+------+------+------+------+------+------+ -|Linting | |d| | |ip| | |d| | |d| | |d| | |d| | +|Linting | |d| | |d| | |d| | |d| | |d| | |d| | +-----------+------+------+------+------+------+------+ |Testing | |d| | |d| | |d| | |d| | |d| | |d| | +-----------+------+------+------+------+------+------+ @@ -106,7 +106,7 @@ This project is divided into several Makefiles, connected by a root Makefile whi +-----------+------+------+------+------+------+------+ |:prob:`3` | |d| | | | | |d| | |d| | +-----------+------+------+------+------+------+------+ -|:prob:`4` | |d| | | |d| | | |d| | |d| | +|:prob:`4` | |d| | | |d| | |d| | |d| | |d| | +-----------+------+------+------+------+------+------+ |:prob:`5` | |d| | | | | |d| | |d| | +-----------+------+------+------+------+------+------+