Skip to content

Instantly share code, notes, and snippets.

@afunTW
Last active March 16, 2016 08:31
Show Gist options
  • Save afunTW/1edc9e6987eba14bb221 to your computer and use it in GitHub Desktop.
Save afunTW/1edc9e6987eba14bb221 to your computer and use it in GitHub Desktop.
Tune the simple API doc of JS

Follow the code style below

// comment
exports.youFunc = function(...){}

usage:

  1. ./tuneExports.py file1 file2 file3
  2. find yourRepo -type f | xargs ./tuneExports.py
#!/usr/bin/python3
import sys
import re
l_file = sys.argv[1:];
for i in l_file:
f = open(i, 'r');
log = open('API.txt', 'a+');
log.write("File: " + i + "\n\n");
lines = f.readlines();
for j in range(0, len(lines)):
if re.match('.*exports\.', lines[j]):
if j>0 and re.match(r'//', lines[j-1]):
log.write(lines[j-1].strip()+ "\n" + lines[j].strip() + "\n\n")
else:
log.write("// FIXME: from " + i + "\n" + lines[j].strip() + "\n\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment