Skip to main content

Generate markdown index of files in folder for mkdocs.

Project description

md-index

Generate markdown index of files in folder for mkdocs.

Install

pip install md-index

Usage

Usage: md-index [OPTIONS]

Options:
  -i, --input-dir PATH        Input directory.
  -o, --output-dir DIRECTORY  Output directory.
  -d, --depth INTEGER         Depth of the file tree to generate, 1 or 2.
  -u, --url-prefix TEXT       Prefix for the URLs in the generated index.
  --help                      Show this message and exit.

The command will generate a folder (default: docs) with a markdown file for each folder in the input directory (default: .). The markdown file will contain a list of files in the folder.

Default depth is 1, which means only the folders in the root of the input directory will be processed. Depth 2 will process the folders in the root and the subfolders. The depth is limited to 2.

Examples

Single level directory

├─folder1
│  ├─file1.txt
│  ├─file2.txt
│  └─file3.txt
├─folder2
│  ├─file1.txt
│  └─file2.txt
└─README.md
md-index

Two-level directory

├─folder1
│  ├─subfolder1
│    ├─file1.txt
│    ├─file2.txt
│    └─file3.txt
│  └─subfolder2
│    └─file1.txt
├─folder2
│  ├─subfolder1
│    └─file1.txt
│  └─subfolder2
│    ├─file1.txt
│    └─file2.txt
└─README.md
md-index --depth=2

Github repository download link

md-index --url-prefix=https://raw.githubusercontent.com/{user}/{repo}/{branch}/

Example processing flow

pip install md-index
pip install mkdocs
cd /path/to/project
md-index
mkdocs build

The generated markdown index is in folder docs and the mkdocs site is in folder site. If you don't have a mkdocs.yml file in the root of the input directory, a simple yml file will be auto generated and set the website name File Index and theme readthedocs.

Automatically publishing a GitHub file repository to Github Pages

name: Build and Deploy
on: [push]
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Install Python 3.10
        uses: actions/setup-python@v4
        with:
          python-version: "3.10"

      - name: Install md-index
        run: pip install md-index

      - name: Install mkdocs
        run: pip install mkdocs

      - name: Build index
        run: md-index
        working-directory: "./"

      - name: Build website
        run: mkdocs build
        working-directory: "./"

      - name: Upload build folder to gh-pages branch
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: "./site"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

md_index-0.1.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

md_index-0.1.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file md_index-0.1.1.tar.gz.

File metadata

  • Download URL: md_index-0.1.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.10 Windows/10

File hashes

Hashes for md_index-0.1.1.tar.gz
Algorithm Hash digest
SHA256 656c621db41395426053205b3dcee4823cd44083118e2907c92b253d1d71bbdf
MD5 c58c537ff72c7d70b75ff066046667f7
BLAKE2b-256 8d36568847a3161fd9a85024bcb686f8a92a9c9ed0a6fab108b6c4c5fa0b0f0e

See more details on using hashes here.

File details

Details for the file md_index-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: md_index-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.10 Windows/10

File hashes

Hashes for md_index-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 563ede2165fe45e90c429e49297378b6b9b41ff48ed4839f9f01e8a36b24d2b6
MD5 e3b4084f57b2cf9a7964f2e83b9519e9
BLAKE2b-256 7531a3ac98468cd87c1c4351b507a8a5870269b816c56b79fcd27e3742bc2c34

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page