From 5f81ef94e033696f85eccbdb8fb3621b2c3dffbf Mon Sep 17 00:00:00 2001 From: Justin DuJardin Date: Fri, 15 Dec 2023 22:44:02 -0800 Subject: [PATCH] chore: prettify the navigation and fix some typos - title up the API and give it a nav section so it's clear where docs end and the API begins - modify docs.py accordingly --- mathy_core/rules/balanced_move.md | 5 +++ mathy_core/rules/restate_subtraction.md | 5 +++ website/docs/api/rules/balanced_move.md | 10 +++++ website/docs/api/rules/restate_subtraction.md | 10 +++++ website/docs/index.md | 2 +- website/mkdocs.yml | 40 +++++++++---------- website/tools/docs.py | 10 ++++- 7 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 mathy_core/rules/balanced_move.md create mode 100644 mathy_core/rules/restate_subtraction.md diff --git a/mathy_core/rules/balanced_move.md b/mathy_core/rules/balanced_move.md new file mode 100644 index 0000000..c0d48c3 --- /dev/null +++ b/mathy_core/rules/balanced_move.md @@ -0,0 +1,5 @@ +Balanced move allows you to move things from one side of an equation to the other, by applying the same operation on both sides. + +### Examples + +`rule_tests:balanced_move` diff --git a/mathy_core/rules/restate_subtraction.md b/mathy_core/rules/restate_subtraction.md new file mode 100644 index 0000000..0e66767 --- /dev/null +++ b/mathy_core/rules/restate_subtraction.md @@ -0,0 +1,5 @@ +Subtraction operations aren't commutable, but addition of negative values are. This flips a subtraction to a plus negation, to "unlock" terms and allow moving them around, e.g. for like-terms simplification. + +### Examples + +`rule_tests:restate_subtraction` diff --git a/website/docs/api/rules/balanced_move.md b/website/docs/api/rules/balanced_move.md index a59f617..3ad7d07 100644 --- a/website/docs/api/rules/balanced_move.md +++ b/website/docs/api/rules/balanced_move.md @@ -2,6 +2,15 @@ import mathy_core.rules.balanced_move ``` +Balanced move allows you to move things from one side of an equation to the other, by applying the same operation on both sides. + +### Examples + +`rule_tests:balanced_move` + + +## API + ## BalancedMoveRule ```python @@ -28,3 +37,4 @@ Supports the following configurations: other. - Multiply is a coefficient of a term that must be divided on both sides of the equation or inequality. + diff --git a/website/docs/api/rules/restate_subtraction.md b/website/docs/api/rules/restate_subtraction.md index be9e113..854226d 100644 --- a/website/docs/api/rules/restate_subtraction.md +++ b/website/docs/api/rules/restate_subtraction.md @@ -2,6 +2,15 @@ import mathy_core.rules.restate_subtraction ``` +Subtraction operations aren't commutable, but addition of negative values are. This flips a subtraction to a plus negation, to "unlock" terms and allow moving them around, e.g. for like-terms simplification. + +### Examples + +`rule_tests:restate_subtraction` + + +## API + ## RestateSubtractionRule ```python @@ -20,3 +29,4 @@ Determine the configuration of the tree for this transformation. Support two types of tree configurations: - Subtraction is a subtract to be restate as a plus negation - PlusNegative is a plus negative const to be restated as subtraction + diff --git a/website/docs/index.md b/website/docs/index.md index 628448b..60e6a76 100644 --- a/website/docs/index.md +++ b/website/docs/index.md @@ -31,7 +31,7 @@ Mathy includes a Computer Algebra System (or CAS). Its job is to turn text into ## Installation ```bash -$ pip install mathy_envs +$ pip install mathy_core ``` ## Examples diff --git a/website/mkdocs.yml b/website/mkdocs.yml index 7c95084..6f28e59 100644 --- a/website/mkdocs.yml +++ b/website/mkdocs.yml @@ -19,27 +19,27 @@ nav: - Home: https://mathy.ai - Core: - Home: index.md - - API: - - expressions: api/expressions.md - - layout: api/layout.md - - parser: api/parser.md - - problems: api/problems.md - - rule: api/rule.md - - rules: - - associative_swap: api/rules/associative_swap.md - - balanced_move: api/rules/balanced_move.md - - commutative_swap: api/rules/commutative_swap.md - - constants_simplify: api/rules/constants_simplify.md - - distributive_factor_out: api/rules/distributive_factor_out.md - - distributive_multiply_across: api/rules/distributive_multiply_across.md - - restate_subtraction: api/rules/restate_subtraction.md - - variable_multiply: api/rules/variable_multiply.md - - testing: api/testing.md - - tokenizer: api/tokenizer.md - - tree: api/tree.md - - util: api/util.md - Releases: changelog.md - License: license.md + - API: + - Expressions: api/expressions.md + - Layout: api/layout.md + - Parser: api/parser.md + - Problems: api/problems.md + - Rule: api/rule.md + - Rules: + - Associative Swap: api/rules/associative_swap.md + - Balanced Move: api/rules/balanced_move.md + - Commutative Swap: api/rules/commutative_swap.md + - Constants Simplify: api/rules/constants_simplify.md + - Distributive Factor Out: api/rules/distributive_factor_out.md + - Distributive Multiply Across: api/rules/distributive_multiply_across.md + - Restate Subtraction: api/rules/restate_subtraction.md + - Variable Multiply: api/rules/variable_multiply.md + - Testing: api/testing.md + - Tokenizer: api/tokenizer.md + - Tree: api/tree.md + - Util: api/util.md - Environments: https://envs.mathy.ai extra: social: @@ -62,6 +62,7 @@ theme: logo: material/hub features: - instant + - navigation.sections - navigation.tabs - navigation.tabs.sticky - navigation.footer @@ -95,6 +96,5 @@ plugins: - search - social - git-revision-date-localized -- git-committers - minify: minify_html: true diff --git a/website/tools/docs.py b/website/tools/docs.py index c234241..8c99350 100644 --- a/website/tools/docs.py +++ b/website/tools/docs.py @@ -26,6 +26,10 @@ yaml = YAML() +def convert_module_to_title(input_string: str) -> str: + return input_string.replace("_", " ").title() + + def prepend_md_content(original_md, prepending_md): with open(prepending_md, "r") as file: prepending_content = file.read() @@ -97,7 +101,9 @@ def process_directory(directory): h1_to_h2(to_file) nav_item = { - file_path.stem: to_file.relative_to(parent_folder_path / "docs").as_posix() + convert_module_to_title(file_path.stem): to_file.relative_to( + parent_folder_path / "docs" + ).as_posix() } nav_entries.append(nav_item) return nav_entries @@ -133,7 +139,7 @@ def main(): if src_folder not in [".", ""]: new_entries = process_directory(folder) new_entries.sort(key=lambda x: list(x)[0]) - nav_entries.append({folder.name: new_entries}) + nav_entries.append({convert_module_to_title(folder.name): new_entries}) else: nav_entries += process_directory(folder) nav_entries.sort(key=lambda x: list(x)[0])