diff --git a/docs/source/conf.py b/docs/source/conf.py index 9d852f2bd..26698769a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,13 +14,31 @@ sys.path.insert(0, os.path.abspath("../..")) + +# Generate the map + +# Add the directory containing your Python script to the Python path +sys.path.insert(0, os.path.abspath(".")) + +import map + +m = map.generate_map() +current_dir = os.path.dirname(__file__) +html_path = os.path.join(current_dir, "_static", "map.html") + +# create _static directory if it doesn't exist +os.makedirs(os.path.dirname(html_path), exist_ok=True) + +m.save(html_path) + # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information project = "FESTIM" -copyright = "2022, Remi Delaporte-Mathurin" -author = "Remi Delaporte-Mathurin" -release = "v0.10.2" +copyright = "2022-2023, FESTIM contributors" +author = "FESTIM-dev" +release = "1.0.0" +version = "1.0" # -- General configuration --------------------------------------------------- @@ -37,10 +55,17 @@ "sphinx.ext.coverage", "sphinx.ext.napoleon", "sphinx.ext.viewcode", + "sphinx_copybutton", "sphinx_design", + "sphinxcontrib.bibtex", "matplotlib.sphinxext.plot_directive", + "sphinxcontrib.images", ] +suppress_warnings = ["autosectionlabel.*"] + +napoleon_use_ivar = True # needed to correctly format class attributes + # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] @@ -62,6 +87,9 @@ # shorten module names in readme add_module_names = False +# bibliography file +bibtex_bibfiles = ["bibliography/references.bib"] + # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for @@ -72,11 +100,41 @@ html_css_files = ["style.css"] html_theme_options = { - "repository_url": "https://github.com/RemDelaporteMathurin/FESTIM", + "repository_url": "https://github.com/festim-dev/FESTIM", "use_repository_button": True, "use_edit_page_button": True, "repository_branch": "main", "path_to_docs": "./docs/source", + "icon_links": [ + { + "name": "PyPI", + "url": "https://pypi.org/project/FESTIM/", + "icon": "https://img.shields.io/pypi/dw/festim", + "type": "url", + }, + { + "name": "Support Forum", + "url": "https://festim.discourse.group/", + "icon": "fa-brands fa-discourse", + }, + { + "name": "Slack", + "url": "https://join.slack.com/t/festim-dev/shared_invite/zt-246hw8d6o-htWASLsbdosUo_2nRKCf9g", + "icon": "fa-brands fa-slack", + }, + ], + "article_header_end": [ + "navbar-icon-links", + "article-header-buttons", + ], +} + +html_sidebars = { + "**": [ + "navbar-logo", + "search-button-field", + "sbt-sidebar-nav", + ], } -html_title = "FESTIM" +html_title = "FESTIM Documentation" diff --git a/docs/source/map.json b/docs/source/map.json new file mode 100644 index 000000000..d6e7ed232 --- /dev/null +++ b/docs/source/map.json @@ -0,0 +1,355 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -84.3101, + 35.9312 + ] + }, + "properties": { + "name": "Oak Ridge National Laboratory", + "path": "images/user_logos/Oak_Ridge_National_Laboratory.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 5.7843, + 43.7254 + ] + }, + "properties": { + "name": "IRFM cadarache France", + "path": "images/user_logos/IRFM_cadarache_France.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 2.3458, + 48.9583 + ] + }, + "properties": { + "name": "LSPM Villetaneuse France", + "path": "images/user_logos/LSPM_Villetaneuse_France.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -71.0921, + 42.3601 + ] + }, + "properties": { + "name": "MIT Cambridge, MA USA", + "path": "images/user_logos/MIT_Cambridge_MA_USA.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -74.6596903, + 40.35006468849364 + ] + }, + "properties": { + "name": "Thea Energy USA", + "path": "images/user_logos/Thea_Energy_USA.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -71.6152, + 42.5406 + ] + }, + "properties": { + "name": "Commonwealth Fusion Systems Devens, MA USA", + "path": "images/user_logos/Commonwealth_Fusion_Systems Devens_MA_USA.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -89.4012, + 43.0761 + ] + }, + "properties": { + "name": "University Wisconsin Madison USA", + "path": "images/user_logos/University_Wisconsin_Madison_USA.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -122.41135340346865, + 37.77479335835942 + ] + }, + "properties": { + "name": "Marathon Fusion USA", + "path": "images/user_logos/Marathon_Fusion_USA.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -117.1611, + 32.7157 + ] + }, + "properties": { + "name": "University San Diego", + "path": "images/user_logos/University_San_Diego.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 37.6649462235042, + 55.66362336404334 + ] + }, + "properties": { + "name": "MEPhI moscow Russia", + "path": "images/user_logos/MEPhI_moscow_Russia.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 5.0266, + 43.5455 + ] + }, + "properties": { + "name": "ITER organization France", + "path": "images/user_logos/ITER_organization_France.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -1.229138717146069, + 51.65868576158049 + ] + }, + "properties": { + "name": "UKAEA UK", + "path": "images/user_logos/UKAEA_UK.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -3.530686738097156, + 50.719235968686455 + ] + }, + "properties": { + "name": "digiLab UK", + "path": "images/user_logos/digiLab_UK.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -0.4269, + 52.0720 + ] + }, + "properties": { + "name": "Cranfield University UK", + "path": "images/user_logos/Cranfield_University_UK.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 7.6818, + 45.0703 + ] + }, + "properties": { + "name": "Politecnico di Torino", + "path": "images/user_logos/Politecnico_di_Torino.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 116.3056, + 39.9923 + ] + }, + "properties": { + "name": "Beihang University", + "path": "images/user_logos/Beihang_University.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 117.2703, + 31.8669 + ] + }, + "properties": { + "name": "Institute of Plasma Physics, Chinese Academy of Sciences", + "path": "images/user_logos/Institute_of_plasma_physics_Chinese_academy_of_sciences.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 14.487728061376515, + 46.043586411058726 + ] + }, + "properties": { + "name": "Institut Jožef Stefan", + "path": "images/user_logos/Institut_Jožef_Stefan.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 139.76446527724698, + 35.68673663876397 + ] + }, + "properties": { + "name": "Kyoto Fusioneering", + "path": "images/user_logos/Kyoto_Fusioneering.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.455144726473035, + 41.818823289415484 + ] + }, + "properties": { + "name": "ENI", + "path": "images/user_logos/ENI.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.670768074076161, + 41.83511773016589 + ] + }, + "properties": { + "name": "ENEA", + "path": "images/user_logos/ENEA.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -122.2637636728507, + 47.94311816450899 + ] + }, + "properties": { + "name": "Zap Energy", + "path": "images/user_logos/Zap_Energy.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -0.3409612613765139, + 51.305321198230246 + ] + }, + "properties": { + "name": "Frazer Nash", + "path": "images/user_logos/Frazer_Nash.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + -0.5894234846558715, + 51.243827970913635 + ] + }, + "properties": { + "name": "University of Surrey", + "path": "images/user_logos/University_of_Surrey.png" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 140.10389, + 36.11139 + ] + }, + "properties": { + "name": "University of Tsukuba", + "path": "images/user_logos/Logo_of_University_of_Tsukuba.png" + } + } + ] +} \ No newline at end of file diff --git a/docs/source/map.py b/docs/source/map.py new file mode 100644 index 000000000..998f45adb --- /dev/null +++ b/docs/source/map.py @@ -0,0 +1,62 @@ +import json +from folium.plugins import MarkerCluster +import folium + +import requests +from PIL import Image +from io import BytesIO + +LOGO_HEIGHT = 60 + + +def generate_map(clustered=True, draggable=False): + # Load GeoJSON data + with open("map.json") as f: + data = json.load(f) + + # Create a map centered on a specific location + m = folium.Map( + location=[42.256349987281666, -37.61204625889672], + zoom_start=3, + tiles="cartodbpositron", + ) + if clustered: + marker_cluster = MarkerCluster().add_to(m) + # Iterate over features in the GeoJSON data + for feature in data["features"]: + name = feature["properties"]["name"] + print(name) + coordinates = feature["geometry"]["coordinates"] + + # Get the dimensions of the image from local images + + if "path" in feature["properties"]: + path = feature["properties"]["path"] + image_dimensions = Image.open(path).size + + if image_dimensions: + height_to_width_ratio = image_dimensions[1] / image_dimensions[0] + image_dimensions = (LOGO_HEIGHT, int(LOGO_HEIGHT * height_to_width_ratio)) + else: + image_dimensions = (LOGO_HEIGHT, LOGO_HEIGHT) + # Create a marker with a custom icon and popup + if coordinates != [0, 0]: + icon = folium.CustomIcon(path, icon_size=image_dimensions) + marker = folium.Marker( + location=[coordinates[1], coordinates[0]], + icon=icon, + draggable=draggable, + ) + if clustered: + marker.add_to(marker_cluster) + else: + marker.add_to(m) + else: + print("no coordinates for", name) + return m + + +if __name__ == "__main__": + m = generate_map(clustered=False, draggable=True) + m.save("map.html") + print("Map saved to map.html")