1
- from generate_docs .markdown import MarkdownPage , build_doc_link , verify_link
1
+ from generate_docs .markdown import MarkdownPage , build_doc_link , verify_link , build_req_link
2
2
from generate_docs .repo import Repo , LanguageCollection
3
3
4
4
5
5
def _get_intro_text (language : LanguageCollection ) -> str :
6
6
introduction = f"Welcome to Sample Programs in { language .get_readable_name ()} !"
7
7
docs = f"""To find documentation related to the { language .get_readable_name ()}
8
- code in this repo, look [here]({ language .sample_program_url } ).
9
- """
10
- interlude_valid = "Otherwise, below you'll find a list of code snippets in this collection."
11
- interlude_invalid = "Below, you'll find a list of code snippets in this collection."
12
- emojis = """
13
- Code snippets preceded by :warning: link to a GitHub
14
- issue query featuring a possible article request issue. If an article request issue
15
- doesn't exist, we encourage you to create one. Meanwhile, code snippets preceded
16
- by :white_check_mark: link to an existing article which provides further documentation.
17
- """
8
+ code in this repo, look [here]({ language .sample_program_url } )."""
18
9
if not verify_link (language .sample_program_url ):
19
- return " " . join ([ introduction , interlude_invalid , emojis ])
10
+ return introduction
20
11
else :
21
- return " " .join ([introduction , docs , interlude_valid , emojis ])
12
+ return " " .join ([introduction , docs ])
13
+
14
+
15
+ def _get_sample_programs_text () -> str :
16
+ return """Below, you'll find a list of code snippets in this collection.
17
+ Code snippets preceded by :warning: link to a GitHub
18
+ issue query featuring a possible article request issue. If an article request issue
19
+ doesn't exist, we encourage you to create one. Meanwhile, code snippets preceded
20
+ by :white_check_mark: link to an existing article which provides further documentation."""
22
21
23
22
24
23
def _generate_program_list (language : LanguageCollection ) -> list :
@@ -31,13 +30,45 @@ def _generate_program_list(language: LanguageCollection) -> list:
31
30
for program in language .sample_programs :
32
31
readable_name = program .normalized_name .replace ("-" , " " ).title ()
33
32
doc_link = build_doc_link (program , f"{ readable_name } in { language .get_readable_name ()} " )
34
- list_items .append (f"- { doc_link } " )
33
+ req_link = build_req_link (program )
34
+ list_items .append (f"- { doc_link } [{ req_link } ]" )
35
35
return list_items
36
36
37
37
38
+ def _generate_testing_section (language : LanguageCollection ):
39
+ test_data = language .get_test_data ()
40
+ if not test_data :
41
+ return """This language currently does not feature testing. If you'd like to help in the efforts to test all
42
+ of the code in this repo, consider creating a testinfo.yml file with the following information:
43
+
44
+ ```yml
45
+ folder:
46
+ extension:
47
+ naming:
48
+
49
+ container:
50
+ image:
51
+ tag:
52
+ cmd:
53
+ ```
54
+
55
+ See the [Glotter project](https://github.com/auroq/glotter) for more information on how to create a testinfo file.
56
+ """
57
+ else :
58
+ return f"""The following list shares details about what we're using to test all Sample Programs in
59
+ { language .get_readable_name ()} .
60
+
61
+ - Docker Image: { test_data ["container" ]["image" ]}
62
+ - Docker Tag: { test_data ["container" ]["tag" ]}
63
+
64
+ See the [Glotter project](https://github.com/auroq/glotter) for more information on how we handle testing.
65
+ """
66
+
67
+
38
68
def _generate_credit ():
39
- return """This page was generated automatically by the Sample Programs Docs Generator.
40
- Find out how to support this project [here](https://github.com/TheRenegadeCoder/sample-programs-docs-generator)."""
69
+ return """---
70
+ This page was generated automatically by the Sample Programs Docs Generator.
71
+ Find out how to support this project [here](https://github.com/TheRenegadeCoder/sample-programs-docs-generator)."""
41
72
42
73
43
74
class ReadMeCatalog :
@@ -61,13 +92,26 @@ def _build_readme(self, language: LanguageCollection) -> None:
61
92
:return: None
62
93
"""
63
94
page = MarkdownPage ("README" )
95
+
96
+ # Introduction
64
97
page .add_content (f"# Sample Programs in { language .get_readable_name ()} " )
65
98
page .add_section_break ()
66
99
page .add_content (_get_intro_text (language ))
67
100
page .add_section_break ()
101
+
102
+ # Sample Programs List
103
+ page .add_content ("## Sample Programs List" )
104
+ page .add_section_break ()
105
+ page .add_content (_get_sample_programs_text ())
106
+ page .add_section_break ()
68
107
page .add_content (* _generate_program_list (language ))
69
108
page .add_section_break ()
109
+
110
+ # Testing
111
+ page .add_content ("## Testing" )
112
+ page .add_content (_generate_testing_section (language ))
70
113
page .add_content (_generate_credit ())
114
+
71
115
self .pages [language .name ] = page
72
116
73
117
def _build_readmes (self ) -> None :
0 commit comments