Metadata-Version: 2.4
Name: simple-sphinx-xml-sitemap
Version: 0.1.2
Summary: A simple Sphinx extension that generates an XML sitemap from navigation pages.
Author: Matthew Rideout
License: MIT License
        
        Copyright (c) 2025 Matthew Rideout
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/mdrideout/simple-sphinx-xml-sitemap
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Sphinx>=4
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Dynamic: license-file

# Simple Sphinx XML Sitemap Extension

[![CI](https://github.com/mdrideout/simple-sphinx-xml-sitemap/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/mdrideout/simple-sphinx-xml-sitemap/actions/workflows/tests.yml)

This project provides a minimal Sphinx extension that generates an XML sitemap
for your documentation.  The extension inspects the navigation structure of your
project and writes a `sitemap.xml` file after the HTML build step completes.

The extension does not support internationalisation or multiple languages, but
it is suitable for most single language documentation sites.

## Installation

Install from PyPI using `pip`:

```bash
pip install simple-sphinx-xml-sitemap
```

Alternatively add it to your `pyproject.toml` or `requirements.txt` file.

## Usage

Add the extension to the `extensions` list in your Sphinx `conf.py` file and
set `html_baseurl` to the public URL where the documentation will be hosted.

```python
extensions = [
    # other extensions
    'simple_sphinx_xml_sitemap', # note the user of underscores
]

html_baseurl = 'https://example.com/docs/'
```

Build your documentation as normal.  The `sphinx-build` command becomes
available after installing the project's dependencies (for example with
`uv`):

```bash
sphinx-build -b html docs docs/_build
```

After the build completes a `sitemap.xml` file will be present in the output
folder.

## Examples

The `examples/` directory contains small projects showing different ways to use
the extension. The project is configured as a uv workspace so these examples can
declare `simple-sphinx-xml-sitemap` as a dependency in their own
`pyproject.toml` files.

### docs

This directory contains only a Sphinx project.  To build it run:

```bash
cd examples/docs
uv venv
source .venv/bin/activate
uv pip install -e .
sphinx-build -b html . _build
```

The example ``conf.py`` excludes the ``.venv`` directory created above so that
Sphinx does not try to parse files inside the virtual environment.

### hello_world

This example is a tiny Python package with a documentation folder and its own
`pyproject.toml`.  Build the docs and install the package in editable mode:

```bash
cd examples/hello_world
uv venv
source .venv/bin/activate
uv pip install -e .
sphinx-build -b html docs docs/_build
```

Both examples will produce a `sitemap.xml` alongside the HTML output.

## Running the tests

Create a virtual environment using `uv`, install the development dependencies,
and run the tests with `pytest -q`:

```bash
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
pytest -q
```

## Why

Search engines often crawl every file of a Sphinx build, including sources and
module documentation pages that may not be useful.  Providing an XML sitemap
allows you to indicate which pages are important and helps search engines index
your documentation correctly.


