Skip to main content

Replace {% include 'file.txt' %} with actual file contents

Project description

Include File

pre-commit

  • Managing documentation is challenging as
  1. Some information ([ex] setting up git command) might come up in multiple documentation
    • put overlaped info in common areas include
  2. Hard to edit
  3. Some files are too large so it's better to put link ([ex] jupyter, data files)
    • convert link to
  4. Need entire file structure or show different instructions per language ([ex] python, java)

Usage

  • See before and after in tests folder
make e2etest

Github CI

  • This pipeline will push to deploy branch
# .github/workflows/main.yml
name: Deploy to deploy branch with include_file

on:
  push:
    branches: ["main"]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python 3.9
        uses: actions/setup-python@v2
        with:
          python-version: "3.9"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install include_file
      - name: Include File
        run: |
          python -m include_file -u $GITHUB_ACTOR -y SUMMARY.md -d deploy -t README.md --stem

      # For deployment add following lines
      - uses: EndBug/add-and-commit@v7
        with:
          message: "Committed by seanhwangg/include_file"
          pull_strategy: NO-PULL
          branch: deploy
          push: origin deploy --force -u

Flags

user

  • -u: github user id used for link ([ex] seanhwangg)

glob

  • -g: Which glob files to include ([ex] "**/*", **/*.md)

path

  • -p: Where to look for include file ([ex] ./.include-file/)

stem

  • -s: Use stem of markdown to overwrite path ([ex] False)
  • includes for REAMD.md are stored in README/include.txt

validate

  • -v: Whether to fail CI in case of include error ([ex] True)

Gitbook Only Flags

Note: These are completely optional for Gitbook users

deploy_branch

  • -d: Change deploy_branch of gitbook ([ex] "deploy")

url_path

table_of_contents

  • -toc: Create table of contents with URL ([ex] "", "table_of_contents.md")

relocate_include

  • -r: Relocate images and include files ([ex] None)

images_overwrite

  • -images: Overwrite default images ([ex] images)

include_overwrite

  • -include: Overwrite default include ([ex] include)

Input

<!-- README.md  -->

* List before include
{% include '.include.txt' %}
* List after include

<!-- include.txt  -->
* I am in include

Result

<!-- README.md -->
* List before include
* I am in include
* List after include

link_overwrite

  • -link: Overwrite default link ([ex] link)

Example

  • Input
<!-- README.md -->
* List before include
{% link 'include.txt' %}
* List after include

<!-- include.txt  -->
* I am in include
  • Result
<!-- REAMD.md -->
* List before include
[include.txt](https://github.com/[user]/[repository]/blob/[deploy_branch]/local.yml)
* List after include

repo_overwrite

  • -repo: Overwrite default repo
  • Default: repo

Input

<!-- README.md  -->
* List before include
{% repo 'include' %}
* List after include

<!-- include/include1.md  -->
* I am in include1

<!-- include/nested/include2.md  -->
* I am in include2

Result

Result on gitbook web

<!-- README.md -->
* List before include

{% tabs %}
{% tab title='include1.md' %}

* I am in include1

{% endtab %}
{% tab title='nested/include2.md' %}

* I am in include2

{% endtab %}
{% endtabs %}

* List after include

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

include-file-0.0.8.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

include_file-0.0.8-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file include-file-0.0.8.tar.gz.

File metadata

  • Download URL: include-file-0.0.8.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for include-file-0.0.8.tar.gz
Algorithm Hash digest
SHA256 518bd3cb28670ee3ad83d77910f0a51cfbb2491a7364101cf6c9ef2bd91ccfd9
MD5 e07a19dae6caa1ecef166f325540b82a
BLAKE2b-256 fd6c729e219cf25d80ae1e7dd98c70f52b2429096e2f47a85fc8e408d60a6e54

See more details on using hashes here.

File details

Details for the file include_file-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: include_file-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for include_file-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 24d078778f0fe03b3d867cb63c5f54a00cfe3d80a55aedfb04bb1ccceb9c1192
MD5 4b43a89c8199b6a7e54f256a9feffa46
BLAKE2b-256 d7328b0963dbca31f237a5969dfd7388059b10b166898c8fa6d9e55a3ddcaee0

See more details on using hashes here.

Supported by

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