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

mdjavadoc-api

v1.0.4

Published

Generates markdown javadocs for use in Jekyll and GitHub Pages.

Downloads

109

Readme

Markdown JavaDoc API

The mdjavadoc-api contains five methods, documented below. Information about the accepted parameters and the behavior of these functions can be found in the project README.

Installation

This is fairly simple.

npm install mdjavadoc-api

Usage

Using the API in your application is pretty easy. For example, this program will parse the file "index.js" and output the resulting markdown to "out.md":

const _mdjd = require('mdjavadoc-api');
_mdjd.generateMarkdownFile("index.js", "out.md");

Another example, this one simply parses "index.js" and prints the parsed data in the console:

const _mdjd = require('mdjavadoc-api');
console.log(_mdjd.parseFile("index.js"));

Options

The options argument on each method is simply an object containing optional arguments which can change the result of the program. These options function as stated below:

| Option Name | Type | Description | |-----------------|------------------|-------------| | template | file (string) | Uses the file as a template to generate markdown, replacing occurences of {{ content }} with the generated docs. | | reg | RegExp | A regular expression to filter out unwanted files (defaults to /^(?!\.).*/, or "any file that does not begin with a ."). | | regdir | RegExp | reg but for directories. | | extensions | boolean | Whether to include the file extensions in the generated content (setting this to true will name files "ClassName.java.md" instead of just "ClassName.md") | | sourcePrefix | string | A string to start all source code URLs with. Defaults to "..". For example, a link to "/api/index.js#L50" will become "../api/index.js#L50". | | breadcrumbs | boolean | Whether to add "breadcrumbs" to the top of each file for navigation. | | breadcrumbsChar | string | The character to separate breadcrumbs with - defaults to " > ". | | index | boolean / string | Whether to generate an index file containing all of the generated docs, and (optionally) the name of the file - defaults to "README.md". By default, this option also generates files for internal directories which look into a smaller amount of folders specified by indexLength. | | indexLength | integer | How many directories internal index files should look into - defaults to 3. Setting this value to 0 disables index files for internal directories. | | indexExtensions | boolean | Whether to include file extensions (.md, etc) in index files. | | indexTemplate | file (string) | A template but for index files. Works almost exactly the same way. |

Documentation

Yes, this program has written its own documentation.

setTag

Type: function

Change the template for one of the preset tags. The default tags are defined as:

  • author: ["Name"]
  • version: ["Current Version"]
  • param: ["Parameter Name", "Description"]
  • "return": ["Returned Value"]
  • exception: ["Exception", "Description"]
  • throws: ["Exception", "Description"]
  • see: ["Reference"]
  • link: ["Reference"]
  • since: ["Version"]
  • deprecated: ["Deprecation"]

|Parameter Name|Description| |-----|-----| |tag|The name of the tag (without the leading '@').| |template|The template to use for the tag (a string array).|

Returned Value: An object containing all of the current tags.

generateMarkdownFiles

Type: function

Generates a set of markdown docs from the files in a directory.

|Parameter Name|Description| |-----|-----| |dir|The directory to generate the docs from.| |out|The directory in which to place generated files.| |options|Optional arguments. |

generateMarkdownFile

Type: function

Generates a markdown doc from the specified file.

|Parameter Name|Description| |-----|-----| |file|The file to generate the docs from.| |out|The file to output the markdown into.| |options|Optional arguments. |

formMarkdown

Type: function

Form basic markdown from an array of parsed data.

|Parameter Name|Description| |-----|-----| |data|The parsed data (returned by parseFile) to generate markdown from.| |options|Optional arguments.|

Returned Value: A string of the markdown formatted docs.

parseDirectory

Type: function

Parses docs for all of the files in a directory.

|Parameter Name|Description| |-----|-----| |dir|The starting directory to parse files from.| |prefix|Internally used prefix to append to package names.| |reg|A regex statement to match file names to.|

Returned Value: An array of the docs fetched from each file.

parseFile

Type: function

Parses the docs in a specific file. Docs are formatted as follows:

{ 
  name: "methodName", 
  description: "This method does a thing with something and somethingelse.", 
  type: ["function"], // basically an array of anything that comes before the method name 
  source: "/package/structure/ClassName.java#L247", 
  param: [ // all tags are added to the map 
    { 
      content: "@param something The thing for the stuff.", 
      template: ["Parameter Name", "Description"], 
      values: ["something", "The thing for the stuff."] 
    }, 
    { 
      content: "@param somethingelse The other thing for the stuff.", 
      template: ["Parameter Name", "Description"], 
      values: ["somethingelse", "The thing for the stuff."] 
    } 
  ] 
} 

|Parameter Name|Description| |-----|-----| |file|The file to parse docs from.| |prefix|The prefix to add to the doc packages.| |options|Optional arguments.|

Returned Value: An array of the parsed docs for the file.