make_readme.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/env python3
  2. """
  3. .. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
  4. """
  5. import os.path
  6. import sys
  7. from path import Path
  8. from readmemaker import ReadmeMaker
  9. PROJECT_NAME = "DateTimeRange"
  10. OUTPUT_DIR = ".."
  11. def write_examples(maker):
  12. maker.set_indent_level(0)
  13. maker.write_chapter("Examples")
  14. example_root = Path(os.path.join("pages", "examples"))
  15. example_files = [
  16. "Create_and_convert_to_string.rst",
  17. "Create_from_a_string.rst",
  18. "Get_iterator.rst",
  19. "Test_whether_a_value_within_the_time_range.rst",
  20. "Test_whether_a_value_intersect_the_time_range.rst",
  21. "Make_an_intersected_time_range.rst",
  22. "Make_an_encompassed_time_range.rst",
  23. "Truncate_time_range.rst",
  24. ]
  25. for example_file in example_files:
  26. maker.write_file(example_root.joinpath(example_file))
  27. maker.inc_indent_level()
  28. maker.write_chapter("For more information")
  29. maker.write_lines(
  30. [
  31. "More examples are available at ",
  32. "https://datetimerange.rtfd.io/en/latest/pages/examples/index.html",
  33. "",
  34. "Examples with Jupyter Notebook is also available at "
  35. "`DateTimeRange.ipynb <https://nbviewer.jupyter.org/github/thombashi/DateTimeRange/"
  36. "tree/master/examples/DateTimeRange.ipynb>`__",
  37. ]
  38. )
  39. def main():
  40. maker = ReadmeMaker(
  41. PROJECT_NAME,
  42. OUTPUT_DIR,
  43. is_make_toc=True,
  44. project_url=f"https://github.com/thombashi/{PROJECT_NAME}",
  45. )
  46. maker.write_chapter("Summary")
  47. maker.write_introduction_file("summary.txt")
  48. maker.write_introduction_file("badges.txt")
  49. write_examples(maker)
  50. maker.write_introduction_file("installation.rst")
  51. maker.set_indent_level(0)
  52. maker.write_chapter("Documentation")
  53. maker.write_lines(["https://datetimerange.rtfd.io/"])
  54. maker.write_file(maker.doc_page_root_dir_path.joinpath("sponsors.rst"))
  55. return 0
  56. if __name__ == "__main__":
  57. sys.exit(main())