Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(maps): jupyter notebook now auto-updates docs site #27003

Merged
merged 4 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/superset-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, curious why this was/is neeeded?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was indeed to get around this:

image

persist-credentials: false
submodules: recursive
- name: Check npm lock file version
Expand Down
102 changes: 102 additions & 0 deletions docs/data/countries.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"countries": [
"Afghanistan",
"Albania",
"Algeria",
"Argentina",
"Australia",
"Austria",
"Belgium",
"Bolivia",
"Brazil",
"Bulgaria",
"Burundi",
"Canada",
"Chile",
"China",
"Colombia",
"Costa Rica",
"Cuba",
"Cyprus",
"Czech Republic",
"Denmark",
"Dominican Republic",
"Ecuador",
"Egypt",
"El Salvador",
"Estonia",
"Ethiopia",
"France",
"France (regions)",
"Finland",
"Germany",
"Guatemala",
"Haiti",
"Honduras",
"Iceland",
"India",
"Indonesia",
"Iran",
"Italy",
"Italy (regions)",
"Japan",
"Jordan",
"Kazakhstan",
"Kenya",
"Korea",
"Kuwait",
"Kyrgyzstan",
"Latvia",
"Liechtenstein",
"Lithuania",
"Malaysia",
"Mexico",
"Morocco",
"Myanmar",
"Netherlands",
"Nicaragua",
"Nigeria",
"Norway",
"Oman",
"Pakistan",
"Panama",
"Papua New Guinea",
"Paraguay",
"Peru",
"Philippines",
"Philippines (regions)",
"Portugal",
"Poland",
"Puerto Rico",
"Qatar",
"Russia",
"Rwanda",
"Saint Barthelemy",
"Saint Martin",
"Saudi Arabia",
"Singapore",
"Slovenia",
"Spain",
"Sri Lanka",
"Sweden",
"Switzerland",
"Syria",
"Tajikistan",
"Tanzania",
"Thailand",
"Timorleste",
"Turkey",
"Turkey (regions)",
"Turkmenistan",
"Uganda",
"UK",
"Ukraine",
"United Arab Emirates",
"Uruguay",
"USA",
"Uzbekistan",
"Venezuela",
"Vietnam",
"Zambia"
]
}
103 changes: 7 additions & 96 deletions docs/docs/configuration/country-map-tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ sidebar_position: 10
version: 1
---

import countriesData from '../../data/countries.json';

## The Country Map Visualization

The Country Map visualization allows you to plot lightweight choropleth maps of
Expand All @@ -21,102 +23,11 @@ The current list of countries can be found in the src

The Country Maps visualization already ships with the maps for the following countries:

- Afghanistan
- Albania
- Algeria
- Argentina
- Australia
- Austria
- Belgium
- Bolivia
- Brazil
- Bulgaria
- Burundi
- Canada
- Chile
- China
- Colombia
- Costa Rica
- Cuba
- Cyprus
- Denmark
- Dominican Republic
- Ecuador
- Egypt
- El_salvador
- Estonia
- Ethiopia
- France
- France Regions
- Finland
- Germany
- Guatemala
- Haiti
- Honduras
- Iceland
- India
- Indonesia
- Iran
- Italy
- Italy Regions
- Japan
- Jordan
- Kazakhstan
- Kenya
- Korea
- Kuwait
- Kyrgyzstan
- Latvia
- Liechtenstein
- Lithuania
- Malaysia
- Mexico
- Morocco
- Myanmar
- Netherlands
- Nicaragua
- Nigeria
- Norway
- Oman
- Pakistan
- Panama
- Papua New Guinea
- Paraguay
- Peru
- Philippines
- Portugal
- Poland
- Puerto_rico
- Qatar
- Russia
- Rwanda
- Saint Barthelemy
- Saint Martin
- Saudi Arabia
- Singapore
- Slovenia
- Spain
- Sri Lanka
- Sweden
- Switzerland
- Syria
- Tajikistan
- Tanzania
- Thailand
- Timorleste
- Turkey
- Turkey Regions
- Turkmenistan
- Uganda
- Uk
- Ukraine
- United Arab Emirates
- Uruguay
- USA
- Uzbekistan
- Venezuela
- Vietnam
- Zambia
<ul style={{columns: 3}}>
{countriesData.countries.map((country, index) => (
<li key={index}>{country}</li>
))}
</ul>

## Adding a New Country

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 77,
"metadata": {},
"outputs": [],
"source": [
"# Dependencies\n",
"\n",
"import os\n",
"import json\n",
"import requests\n",
"import geopandas as gpd\n",
"import matplotlib.pyplot as plt\n",
Expand Down Expand Up @@ -2590,28 +2591,26 @@
"id": "Fb58eGlIt1LW"
},
"source": [
"## Output Typescript"
"## Output Typescript & JSON for Docs Site"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": 51,
"execution_count": 80,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"TypeScript code written to src/countries.ts\n"
"TypeScript code written to src/countries.ts\n",
"JSON written to docs/data/countries.json\n"
]
}
],
"source": [
"\n",
"\n",
"# Function to convert country name to a valid JavaScript identifier\n",
"def to_js_identifier(name):\n",
" return name.replace(' ', '_').replace('-', '_')\n",
Expand Down Expand Up @@ -2677,8 +2676,33 @@
"with open(\"../src/countries.ts\", \"w\") as file:\n",
" file.write(typescript_code)\n",
"\n",
"print(\"TypeScript code written to src/countries.ts\")"
"print(\"TypeScript code written to src/countries.ts\")\n",
"\n",
"# DOCS JSON:\n",
"# Replace underscores with spaces and title-case each country name\n",
"formatted_countries = [country.replace(\"_\", \" \") for country in countries]\n",
"formatted_countries = [country.upper() if country in {\"usa\", \"uk\"} else country.title() for country in formatted_countries]\n",
"formatted_countries = [country.replace(\" Regions\",\" (regions)\") for country in formatted_countries]\n",
"\n",
"\n",
"# Create a dictionary in the desired format\n",
"data = {\"countries\": formatted_countries}\n",
"# Convert the dictionary to a JSON string with proper formatting\n",
"json_data = json.dumps(data, indent=2) + \"\\n\"\n",
"\n",
"# Write to a file\n",
"with open(\"../../../../docs/data/countries.json\", \"w\") as file:\n",
" file.write(json_data)\n",
"\n",
"print(\"JSON written to docs/data/countries.json\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading