gen_index.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. __author__ = "Feng Gu"
  2. __email__ = "contact@fenggu.me"
  3. """
  4. isort:skip_file
  5. """
  6. import os
  7. readme_path = os.path.join(
  8. os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
  9. "README.md",
  10. )
  11. output_path = os.path.join(
  12. os.path.dirname(os.path.dirname(__file__)),
  13. "index.md",
  14. )
  15. sections = []
  16. all_text = """---
  17. hide-toc: true
  18. firstpage:
  19. lastpage:
  20. ---\n"""
  21. index_toctree = """
  22. ```{toctree}
  23. :hidden:
  24. :caption: Introduction
  25. content/installation
  26. content/basic_usage
  27. content/pubs
  28. ```
  29. ```{toctree}
  30. :hidden:
  31. :caption: Wrappers
  32. api/wrappers
  33. ```
  34. ```{toctree}
  35. :hidden:
  36. :caption: Environments
  37. environments/design
  38. environments/index
  39. ```
  40. ```{toctree}
  41. :hidden:
  42. :caption: Development
  43. Github <https://github.com/Farama-Foundation/MiniGrid>
  44. Donate <https://farama.org/donations>
  45. Contribute to the Docs <https://github.com/Farama-Foundation/MiniGrid/blob/master/.github/PULL_REQUEST_TEMPLATE.md>
  46. ```
  47. """
  48. # gen index.md
  49. with open(readme_path) as f:
  50. readme = f.read()
  51. """
  52. sections = [description, publications, installation, basic usage, wrappers, design, included environments&etc]
  53. """
  54. sections = readme.split("<br>")
  55. all_text += sections[0]
  56. all_text += sections[2]
  57. all_text += index_toctree
  58. with open(output_path, "w") as f:
  59. f.write(all_text)
  60. """
  61. 1. gen index.md
  62. 2. gen /environments/index.md
  63. 3. gen /environments/design.md
  64. """