|
@@ -1,3 +1,5 @@
|
|
|
|
+import minigrid.wrappers
|
|
|
|
+
|
|
__author__ = "Feng Gu"
|
|
__author__ = "Feng Gu"
|
|
__email__ = "contact@fenggu.me"
|
|
__email__ = "contact@fenggu.me"
|
|
|
|
|
|
@@ -5,14 +7,19 @@ __email__ = "contact@fenggu.me"
|
|
isort:skip_file
|
|
isort:skip_file
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
+import inspect
|
|
import os
|
|
import os
|
|
import re
|
|
import re
|
|
|
|
|
|
from gymnasium.envs.registration import registry
|
|
from gymnasium.envs.registration import registry
|
|
from tqdm import tqdm
|
|
from tqdm import tqdm
|
|
-
|
|
|
|
from utils import trim
|
|
from utils import trim
|
|
|
|
|
|
|
|
+readme_path = os.path.join(
|
|
|
|
+ os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
|
|
|
|
+ "README.md",
|
|
|
|
+)
|
|
|
|
+
|
|
LAYOUT = "env"
|
|
LAYOUT = "env"
|
|
|
|
|
|
pattern = re.compile(r"(?<!^)(?=[A-Z])")
|
|
pattern = re.compile(r"(?<!^)(?=[A-Z])")
|
|
@@ -20,6 +27,7 @@ pattern = re.compile(r"(?<!^)(?=[A-Z])")
|
|
all_envs = list(registry.values())
|
|
all_envs = list(registry.values())
|
|
|
|
|
|
filtered_envs_by_type = {}
|
|
filtered_envs_by_type = {}
|
|
|
|
+env_names = []
|
|
|
|
|
|
# Obtain filtered list
|
|
# Obtain filtered list
|
|
for env_spec in tqdm(all_envs):
|
|
for env_spec in tqdm(all_envs):
|
|
@@ -33,10 +41,9 @@ for env_spec in tqdm(all_envs):
|
|
env_name = split[1]
|
|
env_name = split[1]
|
|
filtered_envs_by_type[env_name] = env_spec
|
|
filtered_envs_by_type[env_name] = env_spec
|
|
|
|
|
|
-
|
|
|
|
filtered_envs = {
|
|
filtered_envs = {
|
|
- k.split(":")[1]: v
|
|
|
|
- for k, v in sorted(
|
|
|
|
|
|
+ env[0]: env[1]
|
|
|
|
+ for env in sorted(
|
|
filtered_envs_by_type.items(),
|
|
filtered_envs_by_type.items(),
|
|
key=lambda item: item[1].entry_point.split(".")[1],
|
|
key=lambda item: item[1].entry_point.split(".")[1],
|
|
)
|
|
)
|
|
@@ -48,7 +55,12 @@ for env_name, env_spec in filtered_envs.items():
|
|
docstring = trim(made.unwrapped.__doc__)
|
|
docstring = trim(made.unwrapped.__doc__)
|
|
|
|
|
|
pascal_env_name = env_spec.id.split("-")[1]
|
|
pascal_env_name = env_spec.id.split("-")[1]
|
|
- snake_env_name = pattern.sub("_", pascal_env_name).lower()
|
|
|
|
|
|
+ # remove suffix
|
|
|
|
+ p = re.compile(r"([A-Z][a-z]+)*")
|
|
|
|
+ name = p.search(pascal_env_name).group()
|
|
|
|
+
|
|
|
|
+ snake_env_name = pattern.sub("_", name).lower()
|
|
|
|
+ env_names.append(snake_env_name)
|
|
title_env_name = snake_env_name.replace("_", " ").title()
|
|
title_env_name = snake_env_name.replace("_", " ").title()
|
|
|
|
|
|
v_path = os.path.join(
|
|
v_path = os.path.join(
|
|
@@ -75,3 +87,136 @@ title: {title_env_name}
|
|
file = open(v_path, "w+", encoding="utf-8")
|
|
file = open(v_path, "w+", encoding="utf-8")
|
|
file.write(all_text)
|
|
file.write(all_text)
|
|
file.close()
|
|
file.close()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# gen /environments/index.md
|
|
|
|
+index_texts = """---
|
|
|
|
+firstpage:
|
|
|
|
+lastpage:
|
|
|
|
+---
|
|
|
|
+
|
|
|
|
+"""
|
|
|
|
+env_index_toctree = """
|
|
|
|
+```{toctree}
|
|
|
|
+:hidden:
|
|
|
|
+"""
|
|
|
|
+sections = []
|
|
|
|
+
|
|
|
|
+with open(readme_path) as f:
|
|
|
|
+ readme = f.read()
|
|
|
|
+
|
|
|
|
+ """
|
|
|
|
+ sections = [description, publications, installation, basic usage, wrappers, design, included environments&etc]
|
|
|
|
+ """
|
|
|
|
+ sections = readme.split("<br>")
|
|
|
|
+ index_texts += sections[6]
|
|
|
|
+ index_texts += env_index_toctree
|
|
|
|
+
|
|
|
|
+ for env_name in env_names:
|
|
|
|
+ index_texts += env_name + "\n"
|
|
|
|
+
|
|
|
|
+ index_texts += """\n```\n"""
|
|
|
|
+ f.close()
|
|
|
|
+
|
|
|
|
+output_path = os.path.join(
|
|
|
|
+ os.path.dirname(os.path.dirname(__file__)),
|
|
|
|
+ "environments",
|
|
|
|
+ "index.md",
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+# output index.md
|
|
|
|
+with open(output_path, "w+") as f:
|
|
|
|
+ f.write(index_texts)
|
|
|
|
+ f.close()
|
|
|
|
+
|
|
|
|
+# gen /environments/design.md
|
|
|
|
+design_path = os.path.join(
|
|
|
|
+ os.path.dirname(os.path.dirname(__file__)),
|
|
|
|
+ "environments",
|
|
|
|
+ "design.md",
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+design_texts = """---
|
|
|
|
+layout: "contents"
|
|
|
|
+title: Design
|
|
|
|
+firstpage:
|
|
|
|
+---\n"""
|
|
|
|
+
|
|
|
|
+design_texts += sections[5]
|
|
|
|
+
|
|
|
|
+with open(design_path, "w+") as f:
|
|
|
|
+ f.write(design_texts)
|
|
|
|
+ f.close()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# gen /environments/wrappers.md
|
|
|
|
+
|
|
|
|
+wrappers_path = os.path.join(
|
|
|
|
+ os.path.dirname(os.path.dirname(__file__)),
|
|
|
|
+ "api",
|
|
|
|
+ "wrappers.md",
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+wrappers_texts = (
|
|
|
|
+ """---
|
|
|
|
+title: Wrappers
|
|
|
|
+lastpage:
|
|
|
|
+---\n"""
|
|
|
|
+ + sections[4]
|
|
|
|
+ + "\n"
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+for name, obj in inspect.getmembers(minigrid.wrappers):
|
|
|
|
+ if inspect.isclass(obj) and obj.__doc__ is not None:
|
|
|
|
+ formatted_doc = " ".join(trim(obj.__doc__).split())
|
|
|
|
+ wrappers_texts += f"""## {name}
|
|
|
|
+{formatted_doc}\n\n"""
|
|
|
|
+
|
|
|
|
+with open(wrappers_path, "w+") as f:
|
|
|
|
+ f.write(wrappers_texts)
|
|
|
|
+ f.close()
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# gen content/pubs.md
|
|
|
|
+
|
|
|
|
+pubs_path = os.path.join(
|
|
|
|
+ os.path.dirname(os.path.dirname(__file__)),
|
|
|
|
+ "content",
|
|
|
|
+ "pubs.md",
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+pubs_texts = (
|
|
|
|
+ """---
|
|
|
|
+layout: "contents"
|
|
|
|
+title: Publications
|
|
|
|
+firstpage:
|
|
|
|
+---\n#List of Publications\n"""
|
|
|
|
+ + sections[1]
|
|
|
|
+ + "\n"
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+with open(pubs_path, "w+") as f:
|
|
|
|
+ f.write(pubs_texts)
|
|
|
|
+ f.close()
|
|
|
|
+
|
|
|
|
+# gen content/basic_usage.md
|
|
|
|
+
|
|
|
|
+pubs_path = os.path.join(
|
|
|
|
+ os.path.dirname(os.path.dirname(__file__)),
|
|
|
|
+ "content",
|
|
|
|
+ "basic_usage.md",
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+pubs_texts = (
|
|
|
|
+ """---
|
|
|
|
+layout: "contents"
|
|
|
|
+title: Basic Usage
|
|
|
|
+firstpage:
|
|
|
|
+---\n"""
|
|
|
|
+ + sections[3]
|
|
|
|
+ + "\n"
|
|
|
|
+)
|
|
|
|
+
|
|
|
|
+with open(pubs_path, "w+") as f:
|
|
|
|
+ f.write(pubs_texts)
|
|
|
|
+ f.close()
|