diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e7960bc..b57f2a2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,16 +16,16 @@ jobs: runs-on: ubuntu-latest name: Run Rust CI ๐Ÿฆ€ steps: - - uses: ricardoleal20/pymath_compute/.github/actions/rust_ci@ricardo/AddSolverTests + - uses: ricardoleal20/pymath_compute/.github/actions/rust_ci python_ci: runs-on: ubuntu-latest name: Run Python CI ๐Ÿ steps: - - uses: ricardoleal20/pymath_compute/.github/actions/python_ci@ricardo/AddSolverTests + - uses: ricardoleal20/pymath_compute/.github/actions/python_ci tests_ci: runs-on: ubuntu-latest name: Run tests ๐Ÿงช steps: - - uses: ricardoleal20/pymath_compute/.github/actions/tests_ci@ricardo/AddSolverTests + - uses: ricardoleal20/pymath_compute/.github/actions/tests_ci diff --git a/CHANGELOG.md b/CHANGELOG.md index 38ef5fd..2de3869 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [0.3.2] - 18/07/2024 + +### Added: + +- [Documentation]: Better style for the documentation page +- [Package Info]: Include new package information + +### Fixed + +- [Documentation]: Improve and fix some minor problems on the documentation + ## [0.3.1] - 16/07/2024 ### Added diff --git a/Cargo.lock b/Cargo.lock index 7e34128..0617a05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,7 +93,7 @@ dependencies = [ [[package]] name = "pymath_compute" -version = "0.3.1" +version = "0.3.2" dependencies = [ "pyo3", ] diff --git a/Cargo.toml b/Cargo.toml index 53245c0..4574b53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,20 @@ [package] name = "pymath_compute" -version = "0.3.1" +version = "0.3.2" edition = "2021" +description = "Tool to handle mathematical operations using Variables and Mathematical Expressions." +authors = ["ricardoleal20 "] +homepage = "https://pymath.ricardoleal20.dev" +documentation = "https://pymath.ricardoleal20.dev/docs/" +repository = "https://github.com/ricardoleal20/pymath_compute" +license = "MIT" +readme = "README.md" +keywords = ["scientific_computing", "applied_math", "optimization"] +classifiers = [ + "Topic :: Scientific Development :: Mathematical Optimization", + "Topic :: Scientific Development :: Applied Mathematics", +] + [dependencies] pyo3 = { version = "0.16", features = ["extension-module"] } diff --git a/README.md b/README.md index 449b89f..570618b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@

+[![Actions Status](https://github.com/ricardoleal20/pymath_compute/workflows/Continuous%20Integration%20Workflow%20๐Ÿ‘พ/badge.svg)](https://github.com/ricardoleal20/pymath_compute/actions) +[![PyPI](https://img.shields.io/pypi/v/pymath_compute.svg?style=flat-square)](https://pypi.org/project/pymath_compute/) + **PyMathCompute** is a Python tool designed to handle mathematical variables, create and evaluate mathematical expressions, and perform various mathematical optimizations. This library is ideal for those working in applied mathematics, optimization, and related fields. ## Features diff --git a/docs/__info__.py b/docs/__info__.py index 2c8e035..37a32b7 100644 --- a/docs/__info__.py +++ b/docs/__info__.py @@ -6,7 +6,7 @@ create and evaluate mathematical expressions, and perform various mathematical optimizations. """ -VERSION = "0.2.0" +VERSION = "0.3.2" # Add the URL URL_GITHUB = "https://github.com/ricardoleal20/pymath_compute" diff --git a/docs/components/sidebar.py b/docs/components/sidebar.py index db6b435..f983763 100644 --- a/docs/components/sidebar.py +++ b/docs/components/sidebar.py @@ -8,8 +8,7 @@ from docs import styles # Add a dictionary for the SECTIONS -SIDEBAR_SECTIONS: dict[str, Callable[..., rx.Component]] = {} - +SIDEBAR_SECTIONS: dict[int, dict] = {} def sidebar(route: str) -> rx.Component: """The sidebar. @@ -25,9 +24,8 @@ def sidebar(route: str) -> rx.Component: rx.mobile_and_tablet( __sidebar_mobile_and_tablet_view(route) ), - display=["none", "none", "block"], + # display=["none", "none", "block"], position="sticky", - min_width=styles.SIDEBAR_WIDTH, height="100%", top="0px", border_right=styles.border, @@ -37,21 +35,37 @@ def sidebar(route: str) -> rx.Component: # Sidebar Views # # =============================================== # - def __sidebar_desktop_view(route: str) -> rx.Component: """Desktop view of the Sidebar""" + # Only take those sidebar section that you need + stacks: list[rx.Component] = [] + stacks_group: dict[str, list[dict]] = {} + sorted_sections = sorted(SIDEBAR_SECTIONS) + for i in sorted_sections: + # If it is a group, then save it for later + group = SIDEBAR_SECTIONS[i]["group"] + if group is not None: + if group in stacks_group: + stacks_group[group].append(SIDEBAR_SECTIONS[i]) + else: + stacks_group[group] = [SIDEBAR_SECTIONS[i]] + continue + stacks.append(sidebar_item( + text=SIDEBAR_SECTIONS[i]["title"], + url=SIDEBAR_SECTIONS[i]["route"], + active=SIDEBAR_SECTIONS[i]["route"] == route + )) + # Add the groups + stacks += [ + sidebar_grouper(group_name, group_elements, route) + for group_name, group_elements in stacks_group.items() + ] + return rx.box( rx.vstack( sidebar_header(), rx.vstack( - *[ - sidebar_item( - text=SIDEBAR_SECTIONS[i]["title"], - url=SIDEBAR_SECTIONS[i]["route"], - active=SIDEBAR_SECTIONS[i]["route"] == route - ) - for i in sorted(SIDEBAR_SECTIONS) - ], + *stacks, width="100%", overflow_y="auto", align_items="flex-start", @@ -61,11 +75,42 @@ def __sidebar_desktop_view(route: str) -> rx.Component: sidebar_footer(), height="100dvh", ), + min_width=styles.SIDEBAR_WIDTH, + background=styles.Color.BACKGROUND ) def __sidebar_mobile_and_tablet_view(route: str) -> rx.Component: """Desktop view of the Sidebar""" + # Only take those sidebar section that you need + stacks: list[rx.Component] = [] + stacks_group: dict[str, list[dict]] = {} + # Sort the sections + sorted_sections = sorted(SIDEBAR_SECTIONS) + for i in sorted_sections: + # If it is a group, then save it for later + group = SIDEBAR_SECTIONS[i]["group"] + if group is not None: + if group in stacks_group: + stacks_group[group].append(SIDEBAR_SECTIONS[i]) + else: + stacks_group[group] = [SIDEBAR_SECTIONS[i]] + continue + stacks.append(sidebar_item( + text=SIDEBAR_SECTIONS[i]["title"], + url=SIDEBAR_SECTIONS[i]["route"], + active=SIDEBAR_SECTIONS[i]["route"] == route + )) + # Add the groups + for group_name, group_elements in stacks_group.items(): + # Get the icon + icon = None + for element in group_elements: + if element["group_icon"]: + icon = element["group_icon"] + break + stacks.append(sidebar_grouper(group_name, group_elements, route, icon)) + return rx.vstack( rx.drawer.root( rx.hstack( @@ -129,14 +174,7 @@ def __sidebar_mobile_and_tablet_view(route: str) -> rx.Component: # Add the sidebar sidebar_header(), rx.vstack( - *[ - sidebar_item( - text=SIDEBAR_SECTIONS[i]["title"], - url=SIDEBAR_SECTIONS[i]["route"], - active=SIDEBAR_SECTIONS[i]["route"] == route - ) - for i in sorted(SIDEBAR_SECTIONS) - ], + *stacks, width="100%", align_items="flex-start", padding="1em", @@ -155,7 +193,8 @@ def __sidebar_mobile_and_tablet_view(route: str) -> rx.Component: ), direction="left", ), - width="100%" + width="100%", + min_width="0%" ) # =============================================== # @@ -179,6 +218,8 @@ def sidebar_header() -> rx.Component: rx.icon("github"), color_scheme="gray", variant="soft", + cursor="pointer", + border_radius=styles.BORDER_RADIUS ), href="https://github.com/ricardoleal20/pymath_compute", ), @@ -219,7 +260,8 @@ def sidebar_footer() -> rx.Component: def sidebar_item( text: str, url: str, - active: bool + active: bool, + border: bool = False ) -> rx.Component: """Sidebar item. @@ -230,6 +272,15 @@ def sidebar_item( Returns: rx.Component: The sidebar item component. """ + if active: + border_cond = f"0.5px solid {rx.color('gray', 6)}" + else: + border_cond = rx.cond( + border, + f"1px solid {rx.color('gray', 6)}", + "transparent", + ) + return rx.link( rx.hstack( rx.text( @@ -237,29 +288,89 @@ def sidebar_item( ), bg=rx.cond( active, - rx.color("accent", 2), + styles.Color.PRIMARY.value, "transparent", ), - border=rx.cond( - active, - f"1px solid {rx.color('accent', 6)}", - f"1px solid {rx.color('gray', 6)}", - ), + border=border_cond, color=rx.cond( active, - styles.accent_text_color, + styles.Color.TEXT_SECONDARY.value, styles.text_color, ), align="center", border_radius=styles.BORDER_RADIUS, width="100%", padding="1em", + _hover={ + "bg": styles.Color.PRIMARY, + "text": styles.Color.TEXT_SECONDARY + } ), href=url, width="100%", + underline="none" ) +def sidebar_grouper( + title: str, + sub_items: list[dict[str, str]], + route: str, + icon: Optional[rx.Component] = None, +) -> rx.Component: + """Create a grouper for the Sidebar sections using an accordion""" + button_info: list[rx.Component] = [] + + if icon: + button_info.append( + rx.icon(icon, tag=icon, size=25, mapping_right="0.5em")) + button_info.append(rx.text(title, size="2")) + return rx.chakra.accordion( + rx.chakra.accordion_item( + rx.chakra.accordion_button( + rx.hstack( + *button_info, + rx.box(flex_grow=1,), + rx.chakra.accordion_icon(), + bg="transparent", + # border=f"1px solid {rx.color('gray', 6)}", + color=styles.Color.SIDEBAR_TEXT, + align_items="center", + border_radius=styles.BORDER_RADIUS, + border="transparent", + width="100%", + _hover={ + "color": styles.Color.PRIMARY, + } + ) + ), + rx.chakra.accordion_panel( + rx.chakra.accordion( + rx.flex( + *[ + sidebar_item( + text=sub_item["title"], + url=sub_item["route"], + active=sub_item["route"] == route, + border=True, + ) + for sub_item in sub_items + ], + align_items="start", + direction="column", + ), + allow_multiple=True, + ) + ), + width="100%", + align="left", + border="transparent", + ), + height="75%", + width="100%", + allow_multiple=True, + ) + # =============================================== # # Sidebar decorators # # =============================================== # @@ -269,8 +380,10 @@ def sidebar_section( # pylint: disable=R0913 sidebar_title: Optional[str] = None, description: Optional[str] = None, meta: Optional[list[str]] = None, + group: Optional[str] = None, + group_icon: Optional[str] = None, index_position: Optional[int] = None -) -> Callable[..., rx.Component]: +) -> Callable[..., Callable[..., rx.Component]]: """@sidebar_section decorator. It allow us to include extra information about the components, and include @@ -319,7 +432,9 @@ def sidebar_page() -> rx.Component: position = index_position SIDEBAR_SECTIONS[position] = { "title": sidebar_title if sidebar_title else page_title, - "route": route + "route": route, + "group": group, + "group_icon": group_icon } return sidebar_page # Return the wrapper diff --git a/docs/docs.py b/docs/docs.py index f0e77d7..f82420f 100644 --- a/docs/docs.py +++ b/docs/docs.py @@ -5,6 +5,7 @@ import reflex as rx # Import all the pages. from docs.pages import index, documentation_pages +from docs import styles # ========================================== # @@ -24,7 +25,8 @@ ], style={ "font_family": "Montserrat, sans-serif", - "font_size": "13px" + "font_size": "13px", + "background": rx.color("black") } ) diff --git a/docs/pages/documentation.py b/docs/pages/documentation.py index 6361697..063485d 100644 --- a/docs/pages/documentation.py +++ b/docs/pages/documentation.py @@ -11,10 +11,12 @@ @sidebar_section( page_title="Introduction :: PyMath Docs", - route="/docs", - sidebar_title="Introduction" + route="/docs/", + sidebar_title="Introduction", + group="Getting Started", + group_icon="rocket" ) -def introduction() -> rx.Component: +def introduction_guide() -> rx.Component: """Define the introduction to the package""" with open("docs/content/introduction.md", encoding="utf-8") as md_file: content = md_file.read() @@ -27,11 +29,11 @@ def introduction() -> rx.Component: margin_bottom="2em" ) - @sidebar_section( page_title="Basic Usage :: PyMath Docs", - route="/docs/basic_usage", - sidebar_title="Basic Usage" + route="/docs/getting_started/basic_usage", + sidebar_title="Basic Usage", + group="Getting Started" ) def basic_usage() -> rx.Component: """Define the introduction to the package""" @@ -53,6 +55,6 @@ def documentation_pages() -> list[Callable[..., rx.Component]]: """Import and return all the documentation pages""" # In the folder docs/content, read all the .md files available return [ - introduction, - basic_usage + introduction_guide, + basic_usage, ] diff --git a/docs/pages/index.py b/docs/pages/index.py index 3e87eb6..30f25aa 100644 --- a/docs/pages/index.py +++ b/docs/pages/index.py @@ -5,7 +5,7 @@ # Local imports from docs import __info__ as info from docs.components.navbar import navbar -from docs.styles import TextSizes, border_spacer +from docs.styles import TextSizes, border_spacer, Color def index() -> rx.Component: @@ -207,4 +207,5 @@ def footer(): border_top=border_spacer, width="100%", padding_y="3em", + background_color=rx.color_mode_cond(light="white", dark="#111113") ) diff --git a/docs/styles.py b/docs/styles.py index 035478b..accb31a 100644 --- a/docs/styles.py +++ b/docs/styles.py @@ -6,12 +6,13 @@ class Color(Enum): """Include the palette of colors""" - PRIMARY = "#D16F00" - SECONDARY = "#CEF1E6" + PRIMARY = rx.color("teal", 5) + SECONDARY = rx.color("orange", 7) BACKGROUND = "#1E1E1E" BACKGROUND_CONTENT = "#F7F6F6" TEXT = "black" TEXT_SECONDARY = "white" + SIDEBAR_TEXT = rx.color("mauve", 11) class TextSizes(Enum): @@ -98,12 +99,14 @@ class TextSizes(Enum): markdown_style = { "h1": lambda text: rx.heading(text, size=TextSizes.HEADING_H1.value), "code": lambda text: rx.code(text, color_scheme="gray"), - "codeblock": lambda text, **props: rx.code_block(text, **props, margin_y="1em", margin_x="2em"), + "codeblock": lambda text, **props: rx.code_block( + code=text, **props, margin_y="1em", margin_x="2em", + show_line_numbers=True, copy_button=True + ), "a": lambda text, **props: rx.link( text, **props, font_weight="bold", - text_decoration="underline", text_decoration_color=accent_text_color, ), } diff --git a/pyproject.toml b/pyproject.toml index 36747da..18df520 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pymath_compute" -version = "0.3.1" +version = "0.3.2" description = "Tool to handle mathematical operations using Variables and Mathematical Expressions." authors = ["ricardoleal20 "] homepage = "https://pymath.ricardoleal20.dev" @@ -36,6 +36,19 @@ build-backend = "maturin" [tool.maturin] bindings = "pyo3" module-name = "pymath_compute.engine" +description = "Tool to handle mathematical operations using Variables and Mathematical Expressions." +authors = ["ricardoleal20 "] +homepage = "https://pymath.ricardoleal20.dev" +documentation = "https://pymath.ricardoleal20.dev/docs/" +repository = "https://github.com/ricardoleal20/pymath_compute" +license = "MIT" +readme = "README.md" +keywords = ["scientific_computing", "applied_math", "optimization"] +classifiers = [ + "Topic :: Scientific Development :: Mathematical Optimization", + "Topic :: Scientific Development :: Applied Mathematics", +] + [tool.pylint] ignore-paths = ["pymath_compute/engine/*"]