Write annotations inside the function-easily generate JavaScript API Doc

Source: Internet
Author: User

Online Demo HTTP://RUNJS.CN/DETAIL/BJK0ZQFL

(function () {//write JS with closure is the most common method var API = this.    Api = {};    This simple regular is to be used with var ez =/^function.+\ ((. *) \) \s*{\s*\/\*+ ([\s\s]*) \*+\//; Some private methods, which do not expose the API to the user using function private () {///something}////////Api.show are visible to the user, we write the comments into the function Api.s how = function (msg) {/* Alert msg */Alert (MSG)}///Below is the simplest API Doc generation method Api.docez = Docez func        tion Docez (obj) {/** docez generate JavaScript API DOC data is different from extracting annotations directly from the source, ignoring private methods directly.        */var COMMENT,API = object.create (null); obj = obj | |        This for (var name in obj) {if (typeof obj[name]!== ' function ') {continue} comme                NT = Ez.exec (obj[name].tostring ())//no annotations, simple skip if (!comment) Continue api[name]={ PARAMS:COMMENT[1], desc:comment[2]}} return API}///below Extract API documentation and show it in JSON document.getElementById (' Apidoc '). InnerText = Json.stringify (Api.docez (), null,4)}) () 

Write annotations inside the function--easily generate JavaScript API Doc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.