Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

code2snippets

code2snippets is a small utility I wrote to help with blogging. I generally have a handful of codesnippets I want to show, but when I’m writing I’m usually making changes, and

Installing

For now, grab the repo and build

git clone https://github.com/rustyrazorblade/code2snippets.git
cd code2snippets
./gradlew distTar

Usage

In your source code, you’ll want to tag blocks of code using single line comments and a basic marker syntax:

For example, if we have this code:

// :demo
init {
    val delim = types.getOrElse(extension) {
        throw UnsupportedTypeException("Extention $extension not supported, how did you even get here?")
    }
    // spaces, comment, spaces, :marker spaces
    regex = """\s*${delim.s}\s+:([a-z][a-z0-9]*)\s*""".toRegex()
}
// :demo

the utility will extract the lines between the comments, and write a demo.snippet file with the contents. To run the tool:

code2snippets /path/to/source /path/to/destination

Bugs

Please report any bugs as a GitHub Issue.

About

No description, website, or topics provided.

Resources

License

Releases

No releases published

Packages

No packages published