2019-06-13 admin


什么是literate-programming,Fat command line for literate-programming


literate-programming Build Status

This is the fat command-line client for literate-programming-lib. It contains the full functionality for literate programming, including useful commands such as jshint included in it. For a thin client, check out litpro

Full documentation: Literate Programming, MD: How to Treat and Prevent Software Project Mess

This is not done being fully baked, hence v0.9. But this does represent a significant break from 0.8.4. You can take a look at for some observations of mine as I converted from the old version to the new.

Install using npm install literate-programming

Usage is ./node_modules/bin/litpro file and it has some command flags.

If you want a global install so that you just need to write literate-programming then use npm install -g literate-programming.

The library has a full listing of the syntax, commands, and directives. Here we list the flags and new commands and directives.

Example usage

Save the following code to file and run literate-programming

# Welcome

So you want to make a literate program? Let's have a program that outputs
all numbers between 1 to 10.

Let's save it in file count.js

[count.js](#Structure "save: | jshint")

## Structure 

We have some intial setup. Then we will generate the array of numbers. We
end with outputting the numbers. 

    var numarr = [], start=1, end = 11, step = 1;



## Output 

At this point, we have the array of numbers. Now we can join them with a
comma and output that to the console.

    console.log("The numbers are: ", numarr.join(", ") );

## Loop

Set the loop up and push the numbers onto it. 

    var i;
    for (i = start; i < end; i += step) {


For more information, see the documentation book which is free to read online or available for purchase as a PDF.

Some particularly useful syntax sections are:

Use and Security

It is inherently unsecure to compile literate program documents. No effort has been made to make it secure. Compiling a literate program using this program is equivalent to running arbitrary code on your computer. Only compile from trusted sources, i.e., use the same precautions as running a node module.




转载请注明:文章转载自 JavaScript中文网 []