Skip to content

Commit

Permalink
Check and fix broken documentation links. (stripe#4626)
Browse files Browse the repository at this point in the history
  • Loading branch information
michelleb-stripe authored Feb 28, 2022
1 parent a1dc061 commit 2a8842a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
2 changes: 1 addition & 1 deletion payments-core/src/main/java/com/stripe/android/Stripe.kt
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class Stripe internal constructor(
* Handle the [next_action](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-next_action)
* for a previously confirmed [PaymentIntent].
*
* Used for [manual confirmation](https://stripe.com/docs/payments/payment-intents/android-manual) flow.
* Used for [manual confirmation](https://stripe.com/docs/payments/accept-a-payment-synchronously) flow.
*
* @param fragment the `Fragment` that is launching the payment authentication flow
* @param clientSecret the [client_secret](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-client_secret)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ constructor(
/**
* The customer’s bank.
*
* [netbanking.bank](https://stripe.com/docs/payments/netbanking/banks)
* [netbanking.bank](https://stripe.com/docs/js#stripe_create_payment_method-paymentMethodData-netbanking[bank])
*/
@JvmField val bank: String?
) : TypeData() {
Expand Down
67 changes: 67 additions & 0 deletions scripts/check_links_valid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/python
import re
import glob
import os
import sys
import urllib.request
from urllib.error import HTTPError
from urllib.error import URLError

root_dir="docs"
readme="README.md"

def request(url):
try:
print("requesting... ---" + url + "--- ")
response = urllib.request.urlopen(url)
if(response):
return response.getcode() == 200
else:
print("No response\n")
return False
except HTTPError as e:
print("HTTPError \n")
return False
except URLError as e:
print("URLError\n")
return False
print("\n")
return False

def findStripeLinksInFile(filename):
regexStripe = r'(https://stripe.com[^\\)|"|\\ |<]*)'
regexGithub = r'(https://github.com[^\\)|"|\\ |<]*)'
allUrls = []
isFile = os.path.isfile(filename)
if(isFile):
with open(filename) as file:
for line in file:
allUrls.extend(re.findall(regexStripe, line))
allUrls.extend(re.findall(regexGithub, line))
return allUrls


def findStripeLinks(root_dir):
urlSet=set()
for filename in glob.iglob(root_dir + '**/**', recursive=True):
urls = findStripeLinksInFile(filename)
if(urls):
for url in urls:
urlSet.add(url)

return urlSet

##------
# Find the stripe links in the documentation directory
urlSet = findStripeLinks(root_dir)
# Find the stripe links in the Readme
for urlLinkFromReadme in findStripeLinksInFile("README.md"):
urlSet.add(urlLinkFromReadme)

# For each link verify it does not 404 when requested.
urlDNE = []
for url in urlSet:
if(not request(url)):
urlDNE.append(url)
print(urlDNE)
sys.exit(1)

0 comments on commit 2a8842a

Please sign in to comment.