Coder Social home page Coder Social logo

importer's Introduction

Importer

Import any lines, from anywhere

Build Status | GitHub Release Date

Demo

๐ŸŒ„ What is Importer?

Importer is a CLI tool to allow any file to import other file content, including Markdown, YAML, to name a few. Importer uses Importer Markers, which are often provided as comment, to find the relevant file and import defined lines based on line numbers and other details.

Files such as Markdown and YAML which are meant to be a single file input can pull in other files. Importer aims to provide this extra feature without breaking the language syntax. Importer accomplishes this with a code generation approach, where the Markers are used to update the file in place.

This may seem like an unnecessary layer for simple files such as Markdown and YAML, but this allows better structure and code reuse, while retaining or even enhancing code readability.

Marker in Action

You can find more about the details of Importer design here.

โœจ Install

You can get Importer with simple Homebrew command.

$ brew install upsidr/tap/importer

You can also find the relevent binary files under releases.

Other Installation Options

Install with Go

You can also use Go to install.

$ go get github.com/upsidr/importer/cmd/[email protected]

๐ŸŽฎ Commands

Name Description
importer preview FILE Write before/purged/after preview of how Importer processes the file content to stdout.
importer update FILE Run Importer processing on FILE, and update it in place.
importer purge FILE Parse Importer Markers, remove any content within Importer Markers, and update the file in plcae.
importer generate FILE Run Importer processing on FILE, and write the result to stdout.

You can find more about the commands here.

๐Ÿงฉ Supported Files

Because Importer works by parsing language comments, the below are the list of files supported at the moment.

File Type Is Supported? File Extensions Additional Importer Option
Markdown โœ… .md
YAML โœ… .yaml, .yml Indentation
HTML ๐Ÿšง TBC
TOML ๐Ÿšง TBC

To request additional file support, please file an issue from here.

๐Ÿ–‹ Markers

Markers are a simple comment with special syntax Importer understands. Importer is a simple CLI tool, and these markers are the key to make all the import and export to happen. There are several types of markers.

Name Description
Importer Marker Main marker, used to import data from other file.
Exporter Marker Supplemental marker used to define line range in target files.
Skip Importer Update Special marker to suppress importer update.
Auto Generated Note Special marker for importer generate information.

You can find more about the markers here.

๐Ÿš€ Examples

importer preview

importer preview command gives you a quick look at how the file may change when importer update and importer purge are run against the provided file. This is meant to be useful for testing and debugging.

importer-preview-yaml-demo.mp4

importer update

importer update imports based on Importer Markers in the given file, and update the file in place. This is useful for having a single file to manage and also import other file contents. If you want to have a template file which only holds Importer Markers and not actually the imported content, you should use importer generate instead.

importer-update-yaml-demo.mp4

importer purge

importer purge removes any lines between Importer Markers in the given file, and update the file in place. The same operation is executed for importer update before importing all the lines, but this "purge" is sometimes useful to see the file without extra data imported.

importer-purge-yaml-demo.mp4

importer generate

importer generate imports based on Importer Markers in the given file, and write the result to stdout or file. This can be used for debugging, or create a template file with Importer Markers but keep the file purely for Importer Markers.

importer-generate-yaml-demo.mp4

You can find more examples:

:octocat: GitHub Action Integration

Because you can install Importer using Homebrew, you can set up GitHub Action definition such as below:

jobs:
  importer:
    name: Run Importer Generate
    runs-on: ubuntu-latest
    steps:
      - name: Install Importer
        run: brew install upsidr/tap/importer

      - name: Check out
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Run Importer against README.md
        run: importer update README.md
      - name: Check if README.md has any change compared to the branch
        run: |
          git status --short
          git diff-index --quiet HEAD

This repository uses Importer to generate some of the markdown documentation.

You can find actually running CI setup in .github/workflows/importer-ci.yaml.

importer's People

Contributors

rytswd avatar sryoya avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.