Skip to main content

A static HTML directory index generator.

ndx is a command-line utility for generating index files for directories. It supports file annotations via a JSON configuration file.

Installation

pipx install ndx

Usage

To generate an index in a specific directory, use:

ndx /path/to/directory

Generate index files recursively:

ndx --recursive /path/to/directory

Options

usage: ndx [-h] [-r] [--max-depth MAX_DEPTH] [-f] [-v] [--version] directory

Build an annotated index file for a directory.

positional arguments:
directory             path to the target directory

options:
-h, --help            show this help message and exit
-r, --recursive       build index files recursively (default: False)
--max-depth MAX_DEPTH
                        maximum recursion depth for building index files (default: 50)
-f, --force           overwrite existing index.html file(s) (default: False)
-v, --verbose         enable verbose logging (default: False)
--version             show program's version number and exit

Configuration

To customize the index by adding descriptions to the page and files, place a .ndx.json file in the target directory.

Schema

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
        "page": {
            "type": "object",
            "properties": {"description": {"type": "string", "maxLength": 10000}},
            "required": ["description"],
            "additionalProperties": false,
        },
        "files": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name_regex": {
                        "type": "string",
                        "maxLength": 200,
                        "format": "re2-pattern",
                    },
                    "description": {"type": "string", "maxLength": 1000},
                },
                "required": ["name_regex", "description"],
                "additionalProperties": false,
            },
        },
    },
    "additionalProperties": false,
}

Example

{
  "page": {
    "description": "For more information, please refer to the <a href='https://docs.example.com'>documentation</a> website."
  },
  "files": [
    {
      "name_regex": ".*\\.pdf$",
      "description": "Full documentation"
    },
    {
      "name_regex": ".*\\.log$",
      "description": "Build logs"
    }
  ]
}

Design Choices and Limitations

  • Data integrity is only guaranteed on POSIX-compliant systems.

  • Only RE2 regexes are supported.

  • Descriptions only support HTML anchor tags (<a href=''>...</a>).

  • Only HTTPS links are supported in the descriptions.

  • All attributes except the link target are stripped from the HTML anchor tags and target="_blank" is added to them.

  • Hidden files (starting with .) and the index file index.html are skipped.

  • A warning is issued and notes are skipped for files that match multiple regexes.

  • Support for hardlinks on the target directory is required unless the --force option is used.

History

This script was originally developed for the linkmedic project.

License

  • Copyright 2025-2026 M. Farzalipour Tabriz, Max Planck Institute for Physics (MPP)

All rights reserved.

This software may be modified and distributed under the terms of the GPL-3.0 (or later) License. See the LICENSE file for details.

Release files for ndx 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ndx 0.5.0
File Size Uploaded
ndx-0.5.0.tar.gz 20.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ndx 0.5.0
File Interpreter ABI Platform
ndx-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 40.9 kB

Release files / ndx-0.5.0.tar.gz

Download URL ndx-0.5.0.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6bc5b231ec3890067ae6eca1d517c4f1bfbaa4412626de572b7d17d8ceda8d49
BLAKE2b-256 checksum
How to use checksums
81b688642aa9549b7a95623a3f1db810c5ec7eb69f48811a87a18a9e62c0da9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / ndx-0.5.0-py3-none-any.whl

Download URL ndx-0.5.0-py3-none-any.whl
Size 20.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da3fbdd4cb294898e4265864187cc1350c30480a02138f140670792253273f6d
BLAKE2b-256 checksum
How to use checksums
f73ebdbfecec0de1eec702422f500022f94ecca7f68f8fccc0fcf436363e6f17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.6.0

2 release files

This release

0.5.0 This release

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page