Commit 3ab6a52f authored by Dave Machado's avatar Dave Machado Committed by GitHub
Browse files

Merge branch 'master' into master

parents 76c8bf3a b1ad3a00
* text=auto
/build export-ignore
.travis.yml export-ignore
README.md export-ignore
CONTRIBUTING.md export-ignore
language: node_js language: node_js
notifications: notifications:
email: false email: true
before_install: before_install:
- rvm install 2.4.0 - rvm install 2.4.0
install: install:
...@@ -12,3 +12,4 @@ script: ...@@ -12,3 +12,4 @@ script:
after_success: after_success:
- ./build.sh - ./build.sh
- ./deploy.sh - ./deploy.sh
\ No newline at end of file
...@@ -31,6 +31,8 @@ Please continue to follow the alphabetical ordering that is in place per section ...@@ -31,6 +31,8 @@ Please continue to follow the alphabetical ordering that is in place per section
If an API seems to fall into multiple categories, please place the listing within the section most in line with the services offered through the API. For example, the Instagram API is listed under `Social` since it is mainly a social network, even though it could also apply to `Photography`. If an API seems to fall into multiple categories, please place the listing within the section most in line with the services offered through the API. For example, the Instagram API is listed under `Social` since it is mainly a social network, even though it could also apply to `Photography`.
This project now offers a [JSON version](json/) of the list of services. These files are automatically updated as part of the Continuous Integration process, so there is no need to update them as part of the contribution.
## Pull Request ## Pull Request
After you've created a branch on your fork with your changes, it's time to [make a pull request][pr-link]! After you've created a branch on your fork with your changes, it's time to [make a pull request][pr-link]!
...@@ -57,7 +59,9 @@ During the discussion, you may be asked to make some changes to your pull reques ...@@ -57,7 +59,9 @@ During the discussion, you may be asked to make some changes to your pull reques
If so, add more commits to your branch and push them – they will automatically go into the existing pull request! If so, add more commits to your branch and push them – they will automatically go into the existing pull request!
Opening a pull request will trigger a Travis CI build to check the validity of all links in the project. After the build completes, please ensure that the build has passed. Otherwise, view the Travis CI log and see what errors the build found for your contribution. If the build error is not related to your link(s), don't worry! Your pull request will not be delayed because of already existing link causing an error. Opening a pull request will trigger a Travis CI build to check the validity of all links in the project. After the build completes, **please ensure that the build has passed**. If the build did not pass, please view the Travis CI log and correct any errors that were found in your contribution.
Thanks for being a part of this project, and we look forward to hearing from you soon!
[branch-link]: <http://guides.github.com/introduction/flow/> [branch-link]: <http://guides.github.com/introduction/flow/>
[clone-link]: <https://help.github.com/articles/cloning-a-repository/> [clone-link]: <https://help.github.com/articles/cloning-a-repository/>
......
This diff is collapsed.
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# create json directory if not already present # create json directory if not already present
mkdir -p ../json mkdir -p ../json
# parse API README and print (minified) JSON to stdout, redirect to /json # parse API README and print (minified) JSON to stdout, redirect to /json
node md2json.js ../README.md > ../json/entries.min.json node condenseMd.js ../README.md > single_table.md
node md2json.js single_table.md > ../json/entries.min.json
# beautify the previously created JSON file, redirect to /json # beautify the previously created JSON file, redirect to /json
python -m json.tool ../json/entries.min.json > ../json/entries.json python -m json.tool ../json/entries.min.json > ../json/entries.json
fs = require('fs')
function setupMd(filename, anchor) {
fs.readFile(filename, 'utf8', function (err,text) {
if (err) {
return console.log(err);
}
var lines = text.split("\n"),
cur_line = 0,
line = "",
table_name = "",
col_num = 0,
cols = [],
rows = [],
arr = [];
function read_line() {
return lines[cur_line++];
}
while (true) {
var cols = [];
var rows = [];
while (line.indexOf(anchor) == -1 && cur_line != lines.length) {
line = read_line();
}
if (cur_line == lines.length) {
break;
}
table_name = line.split(anchor)[1];
read_line()
read_line()
while (true) {
line = read_line()
if (line.length < 2 || cur_line == lines.length) {
break
}
if (line.startsWith("|")) {
arr.push(line + table_name)
}
}
}
console.log(anchor + " entries")
console.log("API | Description | Auth | HTTPS | Link | Section")
console.log("|---|---|---|---|---|---|")
for (i = 0; i < arr.length; i++) {
console.log(arr[i])
}
});
}
if (process.argv.length < 3) {
console.log("No .md file passed!");
return;
}
if (process.argv.length < 4) {
anchorText = "###";
} else {
anchorText = process.argv[3];
}
setupMd(process.argv[2].toString(), anchorText);
\ No newline at end of file
#!/bin/bash #!/bin/bash
FORMAT_FILE=../README.md FORMAT_FILE=../README.md
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
echo "running on $TRAVIS_BRANCH branch"
LINK_FILE=../README.md
else
echo "running on Pull Request #$TRAVIS_PULL_REQUEST" echo "running on Pull Request #$TRAVIS_PULL_REQUEST"
DIFF_URL="https://patch-diff.githubusercontent.com/raw/toddmotto/public-apis/pull/$TRAVIS_PULL_REQUEST.diff" DIFF_URL="https://patch-diff.githubusercontent.com/raw/toddmotto/public-apis/pull/$TRAVIS_PULL_REQUEST.diff"
curl $DIFF_URL > diff.txt curl $DIFF_URL > diff.txt
...@@ -12,9 +16,6 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then ...@@ -12,9 +16,6 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
cat additions.txt cat additions.txt
echo "------- END ADDITIONS ------" echo "------- END ADDITIONS ------"
LINK_FILE=additions.txt LINK_FILE=additions.txt
else
echo "running on $TRAVIS_BRANCH branch"
LINK_FILE=../README.md
fi fi
echo "running format validation..." echo "running format validation..."
......
...@@ -37,6 +37,7 @@ function handle(filename, anchor) { ...@@ -37,6 +37,7 @@ function handle(filename, anchor) {
var col_num = 0; var col_num = 0;
var cols = []; var cols = [];
var rows = []; var rows = [];
var entry_count = 0;
function read_line() { function read_line() {
return lines[cur_line++]; return lines[cur_line++];
...@@ -100,6 +101,7 @@ function handle(filename, anchor) { ...@@ -100,6 +101,7 @@ function handle(filename, anchor) {
} }
rows.push(row); rows.push(row);
entry_count++;
line = read_line() line = read_line()
} }
...@@ -113,6 +115,7 @@ function handle(filename, anchor) { ...@@ -113,6 +115,7 @@ function handle(filename, anchor) {
data.push(ele); data.push(ele);
} }
} }
root["count"] = entry_count;
root[table_name] = data; root[table_name] = data;
} }
console.log(JSON.stringify(root)); console.log(JSON.stringify(root));
......
This diff is collapsed.
#!/usr/bin/env ruby #!/usr/bin/env ruby
auth_keys = ['apiKey', 'OAuth', 'X-Mashape-Key', 'No'] auth_keys = ['apiKey', 'OAuth', 'X-Mashape-Key', 'No']
punctuation = ['.', '?', '!']
https_keys = ['Yes', 'No'] https_keys = ['Yes', 'No']
args = ARGV
filename = args[0] INDEX_TITLE = 1
fail_flag = false INDEX_DESCRIPTION = 2
File.foreach(filename).with_index do |line, line_num| INDEX_AUTH = 3
INDEX_HTTPS = 4
INDEX_LINK = 5
filename = ARGV[0]
$errors = []
def add_error(line_num, val_index, message)
case val_index
when INDEX_TITLE
segment = "Title"
when INDEX_DESCRIPTION
segment = "Description"
when INDEX_AUTH
segment = "Auth"
when INDEX_HTTPS
segment = "HTTPS"
when INDEX_LINK
segment = "Link"
end
$errors.push("(L%03d) %-14.14s #{message}" % [line_num, segment])
end
File.foreach(filename).with_index do | line, line_num |
line_num += 1 line_num += 1
if line.start_with?('|')
# Skip table schema lines # Skip non-markdown table lines and table schema lines
if line.eql? "|---|---|---|---|---|\n" if !line.start_with?('|') || line.eql?("|---|---|---|---|---|\n")
next next
end end
values = line.split("|")
# Check Description to make sure first character is capitalized values = line.split("|")
desc_val = values[2].lstrip.chop
if !/[[:upper:]]/.match(desc_val[0]) ################### GLOBAL ###################
puts "(#{line_num}) Invalid Description (first char not uppercase): #{desc_val}" values.each.with_index do |val, val_index|
fail_flag = true msg = ""
end case val_index
# Check Auth values to conform to valid options only when INDEX_TITLE..INDEX_LINK
auth_val = values[3].lstrip.chop.tr('``', '') # every line segment should start and end with exactly 1 space
if !auth_keys.include?(auth_val) if val[/\A */].size != 1 || val[/ *\z/].size != 1
puts "(#{line_num}) Invalid Auth (not a valid option): #{auth_val}" add_error(line_num, val_index, "string should start and end with exactly 1 space")
fail_flag = true end
end
# Check HTTPS Support values to be either "Yes" or "No"
https_val = values[4].lstrip.chop
if !https_keys.include?(https_val)
puts "(#{line_num}) Invalid HTTPS: (must use \"Yes\" or \"No\"): #{https_val}"
fail_flag = true
end
# Check Link to ensure url is wrapped in "[Go!]" view
link_val = values[5].lstrip.chop
if !link_val.start_with?("[Go!](") || !link_val.end_with?(')')
puts "(#{line_num}) Invalid Link: (format should be \"[Go!](<LINK>)\"): #{link_val}"
fail_flag = true
end end
end end
################# DESCRIPTION ################
# First character should be capitalized
desc_val = values[INDEX_DESCRIPTION].lstrip.chop
if !/[[:upper:]]/.match(desc_val[0])
add_error(line_num, INDEX_DESCRIPTION, "first char not uppercase")
end
# value should not be punctuated
last_char = desc_val[desc_val.length-1]
if punctuation.include?(last_char)
add_error(line_num, INDEX_DESCRIPTION, "description should not end with \"#{last_char}\"")
end
#################### AUTH ####################
# Values should conform to valid options only
auth_val = values[INDEX_AUTH].lstrip.chop.tr('``', '')
if !auth_keys.include?(auth_val)
add_error(line_num, INDEX_AUTH, "not a valid option: #{auth_val}")
end
#################### HTTPS ###################
# Values should be either "Yes" or "No"
https_val = values[INDEX_HTTPS].lstrip.chop
if !https_keys.include?(https_val)
add_error(line_num, INDEX_HTTPS, "must use \"Yes\" or \"No\": #{https_val}")
end
#################### LINK ####################
# Url should be wrapped in "[Go!]" view
link_val = values[INDEX_LINK].lstrip.chop
if !link_val.start_with?("[Go!](") || !link_val.end_with?(')')
add_error(line_num, INDEX_LINK, "format should be \"[Go!](<LINK>)\": #{link_val}")
end
end end
if fail_flag $errors.each do | e |
exit(1) puts e
else
exit(0)
end end
exit($errors.length)
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment