npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

raml-to-markdown

v1.2.6

Published

Create Markdown documentation out of RAML service definitions.

Downloads

1,312

Readme

raml-to-markdown

Coverage Status

RAML to Markdown is a simple tool to create documentations out of RAML service definitions. Its output is template based to enable developers to change the output structure, style or even the output type e.g. by creating html templates.

This module provides a comfortable APIs and a full featured command line client.

Install

npm install -g raml-to-markdown

Command-line interface

After installing you may use the command-line interface (CLI) on the terminal of your computer. The command is named "raml2md".

raml2md --help

Usage: raml2md [options] [path]

Options:

  -h, --help                 output usage information
  -r, --recursive            Scan <path> recursively.
  -t, --template <template>  Template file to use for output generation.
  -o, --output-type <type>   Where to put the output. Possible values: stdout, file, file-per-resource.
  -f, --output-file <file>   File to output results to if output type is file.
  -p, --output-path <path>   Path to output results to if output type is file-per-resource.
  -c, --config <file>        Path to a JSON config file to use.
  --output-ext <extension>   File extension of result files if output type is file-per-resource.
  --file-filter <regexp>     RegExp for filtering files.

Config file

The config file represents all configuration options available to run the tool from command line. These are almost the same options as shown in the DefaultConfig section of the API description. In order to use the module programmatically, you will have to use the DefaultConfig settings instead.

{
    "input": {
        "paths": [],
        "recursive": false,
        "fileFilter": "\\.raml$",
        "templateFile": "./templates/index.njk"
    },
    "output": {
        "type": "StdOut",
        "file": {
            "splitting": "AllInOne",
            "path": null,
            "extension": ".md"
        }
    }
}

API

You might also want to use the API of this tool as a library. The library provides two methods to call. A parse() and a render() method.

The parse() method returns an array with objects containing all information extracted from the source. Each array index represents one source file parsed.

The render() method does the same but outputs a processed template depending on the input and output settings of the passed configuration object.

Both methods return a Promise object. Depending on the configuration settings, the promise contains the rendered output or undefined.

const raml2md = require('raml-to-markdown');

raml2md.parse({ input : { paths : [ '...' ] } }).then(console.log);
raml2md.render({ input : { paths : [ '...' ] } }).then(console.log);

For configuration options please have a look at the DefaultConfig section.

Templating

This module uses Nunjucks in order to structure the parsed RAML. By changing the provided or creating a new template, you would be able to create almost every formatted text output.

DefaultConfig

{
   input : {
       paths : [ ],
       recursive : false,
       fileFilter : new RegExp('\.raml$'),
       templateFile : './templates/index.njk',
       contentFilter : null
   },
   output : {
       type : this.OutputType.ReturnOnly,
       file : {
           splitting : this.FileSplitting.AllInOne,
           path : null,
           extension : '.md'
       },
       contentFilter : item => item.replace(/\n{3,}/g, "\n\n")
   }
}