Skip to content

Instantly share code, notes, and snippets.

@tedmiston
Created June 28, 2017 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tedmiston/ab26ccc6df837c724c1dce6ff51d1f95 to your computer and use it in GitHub Desktop.
Save tedmiston/ab26ccc6df837c724c1dce6ff51d1f95 to your computer and use it in GitHub Desktop.
astro-metal name stylizer
#!/usr/bin/env python3
"""
A style-izer / PascalCase-r / opinionated capitalizer for the docs site.
Capitalize the names of companies, services, etc as used on various generated
list pages on the Astronomer docs site <https://docs.astronomer.io/>, such as
Sources, Destinations, Transforms, Clickstream Collectors, and Clickstream
Connectors.
Since our repo names are generally lowercase and astro-metal extracts an
integration's name from the name of the repo, the proper noun capitalization
isn't known, which results in e.g., "Github" instead of "GitHub". This
dictionary tracks such overrides to programmatic capitalization.
You can also use it to handle cases such as a repo named "astro-foo" whose
integration title might be better as "Astronomer Foo", or mapping "keen-io" to
"Keen IO".
If you're adding a new capitalization override, please defer to Wikipedia or
the company itself on the preferred stylized capitalization. All lists are in
case insensitive lexicographical order for convenience.
"""
import json
# TODO: move stylized name overrides to a flat config file
# TODO: peruse how the github grab code works and when a doc is generated vs created by hand (or ask noah) - https://github.com/astronomerio/astro-metal/blob/91406b08b9457c5d4ff868daa5213f22184927cc/lib/githubGrab.js#L107
# TODO: note some of these are just current capitalization errors in the docs repo... perhaps it could be a linter rule
with open('overrides.json') as fp:
stylized_names = json.load(fp)
def capitalize_words(name):
return ' '.join(map(str.capitalize, name.split(' ')))
def stylize(name):
return stylized_names.get(name.lower(), capitalize_words(name))
# TODO: pull from programmatic list of names
names = stylized_names.keys()
output = map(stylize, names)
output = sorted(output, key=lambda x: x.casefold())
for name, output in zip(names, output):
print(name, '-->', output)
{
"adwords": "AdWords",
"aha": "Aha!",
"analytics.js": "analytics.js",
"appointmentplus": "AppointmentPlus",
"base crm": "Base CRM",
"bliptrack": "BlipTrack",
"circleci": "CircleCI",
"csv to json": "CSV to JSON",
"currencylayer": "currencylayer",
"desk.com": "Desk.com",
"easypost": "EasyPost",
"exact target": "ExactTarget",
"filter fields": "Filter fields",
"fixer": "Fixer.io",
"flightstats": "FlightStats",
"freshbooks": "FreshBooks",
"github": "GitHub",
"heap analytics": "Heap",
"html table": "HTML table",
"hubspot": "HubSpot",
"import.io": "Import.io",
"ios": "iOS",
"jira": "JIRA",
"json flatten": "JSON flatten",
"json to csv": "JSON to CSV",
"keenio": "Keen IO",
"kissmetrics": "Kissmetrics",
"livevox": "LiveVox",
"mailchimp": "MailChimp",
"meteorjs": "Meteor",
"mongodb": "MongoDB",
"mssql": "SQL Server",
"mysql": "MySQL",
"openweathermap": "OpenWeatherMap",
"paypal": "PayPal",
"postgres": "PostgreSQL",
"postgresql": "PostgreSQL",
"prism": "PRISM Climate Group",
"quickbooks": "QuickBooks",
"s3 merge": "S3 merge",
"sendgrid": "SendGrid",
"streamspot": "StreamSpot",
"surveygizmo": "SurveyGizmo",
"surveymonkey": "SurveyMonkey",
"toggl": "Toggl",
"ups": "UPS",
"value resolve": "Value resolve",
"woocommerce": "WooCommerce",
"wordpress": "WordPress",
"zenhub": "ZenHub"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment