diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 13222d6..f3b58c2 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -11,7 +11,7 @@ This directory contains automated workflows for continuous integration and deplo **Purpose:** Test the package across multiple Python versions and operating systems. **Jobs:** -- **test**: Runs on Python 3.8-3.12 across Ubuntu, macOS, and Windows +- **test**: Runs on Python 3.9-3.12 across Ubuntu, macOS, and Windows - Installs the package - Tests imports - Validates plugin registration with MkDocs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ca4814..f61a2da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] include: - os: macos-latest python-version: "3.12" diff --git a/README.md b/README.md index 99fb2f9..0a0b486 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ Each link in the `links` list supports: - `text` (string, required): The text displayed for the link - `url` (string, optional): The URL the link points to (not needed if using `submenu`) - `target` (string, optional): The target attribute (e.g., `_blank` for new tab) +- `bottom-border` (bool or int, optional): Add bottom divider of width 1px if true, or given value in px if number - `submenu` (list, optional): List of nested links for a submenu (see Nested Dropdowns below) ## Example: Using Shared Config File diff --git a/SETUP_SUMMARY.md b/SETUP_SUMMARY.md index 647c6e3..48d76cb 100644 --- a/SETUP_SUMMARY.md +++ b/SETUP_SUMMARY.md @@ -17,7 +17,7 @@ This document summarizes the changes made to set up this repository for PyPI pub - Added maintainers field - Added `pyyaml` dependency - Enhanced project URLs (Issues, Documentation) -- Updated Python version support (3.7-3.12) +- Updated Python version support (3.9-3.12) - Fixed package data configuration #### `MANIFEST.in` (new) @@ -28,7 +28,7 @@ This document summarizes the changes made to set up this repository for PyPI pub #### `.github/workflows/ci.yml` (new) Tests the package across multiple environments: -- **Python versions**: 3.8, 3.9, 3.10, 3.11, 3.12 +- **Python versions**: 3.9, 3.10, 3.11, 3.12 - **Operating systems**: Ubuntu, macOS, Windows - **Checks**: - Package installation diff --git a/USAGE.md b/USAGE.md index d8b9ddf..57029bf 100644 --- a/USAGE.md +++ b/USAGE.md @@ -108,6 +108,7 @@ Each link in the `links` list supports: | `text` | string | Yes | The link text | | `url` | string | Conditional | The target URL (can be relative or absolute). Required unless `submenu` is provided. Optional when using `submenu` to make the parent clickable. | | `target` | string | No | HTML target attribute (e.g., `_blank` for new tab) | +| `bottom-border` | bool or int | No | Add bottom divider of width 1px if true, or given value in px if number | | `submenu` | list | No | List of nested links (creates a submenu). See Nested Dropdowns below. | ## Advanced Examples diff --git a/mkdocs_header_dropdown/plugin.py b/mkdocs_header_dropdown/plugin.py index 90dde1f..ff278c7 100644 --- a/mkdocs_header_dropdown/plugin.py +++ b/mkdocs_header_dropdown/plugin.py @@ -35,6 +35,34 @@ class HeaderDropdownPlugin(BasePlugin): ('dropdowns', config_options.Type(list, default=[])), ) + def _normalize_links(self, links): + """ + Normalize `border-bottom` value. Default width is 1px if specified + """ + normalized = [] + for link in (links or []): + if not isinstance(link, dict): + normalized.append(link) + continue + item = dict(link) # shallow copy avoid mutating link + value = item.get('border-bottom', None) + style = "" + width = 0 + if value is None: + width = 0 + elif isinstance(value,bool): + width = 1 if value else 0 + elif isinstance(value,str): + valstr = value.lower() + width = 1 if any(v in valstr for v in ['yes','true','on']) else 0 + elif isinstance(value,(int,float)): + width = value + if width>0: + style += f"border-bottom: {width}px solid var(--md-default-fg-color--lightest);" + item['extra_style'] = style + normalized.append(item) + return normalized + def _generate_links_from_yaml(self, data, parent_key=None): """ Recursively generate dropdown links from YAML structure. @@ -162,6 +190,11 @@ def on_config(self, config: MkDocsConfig, **kwargs) -> MkDocsConfig: # 2. Add dropdowns from mkdocs.yml dropdowns.extend(self.config.get('dropdowns', [])) + # Normalize link-level attributes + for dropdown in dropdowns: + if isinstance(dropdown, dict) and isinstance(dropdown.get('links'), list): + dropdown['links'] = self._normalize_links(dropdown['links']) + # Add the dropdowns to extra so templates can access them config.extra['header_dropdowns'] = dropdowns diff --git a/mkdocs_header_dropdown/templates/partials/header-dropdown.html b/mkdocs_header_dropdown/templates/partials/header-dropdown.html index 7a27cbd..a8ed1f9 100644 --- a/mkdocs_header_dropdown/templates/partials/header-dropdown.html +++ b/mkdocs_header_dropdown/templates/partials/header-dropdown.html @@ -28,7 +28,7 @@ {# Top-level link with submenu - clickable link with arrow #} {{ link.text }} @@ -38,7 +38,7 @@ {% else %} {# Top-level item with submenu only - not clickable #} -
{{ link.text }} @@ -52,7 +52,7 @@ {% for sublink in link.submenu %} {{ sublink.text }} @@ -63,7 +63,7 @@ {% else %} {{ link.text }} diff --git a/pyproject.toml b/pyproject.toml index 375c7c1..19dbce8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "mkdocs-header-dropdown" dynamic = ["version"] description = "A MkDocs plugin to add configurable dropdown menus to the Material theme header" readme = "README.md" -requires-python = ">=3.7" +requires-python = ">=3.9" license = "MIT" keywords = ["mkdocs", "plugin", "dropdown", "navigation", "material-theme", "documentation"] authors = [ @@ -23,8 +23,6 @@ classifiers = [ "Topic :: Text Processing :: Markup :: Markdown", "Framework :: MkDocs", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11",