Skip to content

Commit b421a8f

Browse files
authored
Doc automation (oneapi-src#637)
* update * update * misc updates' * updates mis * Update CODESAMPLESLIST.md * format issues * Update README.md * Update README.md * misc updates * Update README.md * update for readability
1 parent c04976e commit b421a8f

File tree

7 files changed

+281
-249
lines changed

7 files changed

+281
-249
lines changed

.repo-tools/Docs_Automation/content.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"mdContribute": "## Contribute\n\nSee [CONTRIBUTING](https://github.com/oneapi-src/oneAPI-samples/blob/master/CONTRIBUTING.md) for more itargetedDevices.ormation.\n\n",
55

6-
"mdIntro1":"The oneAPI samples repository provides code samples for Intel oneAPI toolkits.<br><br>We recommend checking out a specific stable release version of the repository to [View available stable releases](https//github.com/oneapi-src/oneAPI-samples/tags). ",
6+
"mdIntro1":"The oneAPI samples repository provides code samples for Intel oneAPI toolkits.<br><br>We recommend checking out a specific stable release version of the repository. [View available stable releases](https//github.com/oneapi-src/oneAPI-samples/tags). ",
77
"mdIntro2":"The latest versions (",
88
"mdIntro2.1":") of code samples on the master branch are not guaranteed to be stable.",
99
"mdIntro3":"The oneAPI sample repository is organized as follows:",
@@ -12,23 +12,23 @@
1212
"mdIntro3.3":"* [Libraries](https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries)\n * [oneCCl](https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneCCL)\n * [oneDAL](https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneDAL)\n * [oneDNN](https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneDNN)\n * [oneDPL](https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneDPL)\n * [oneMKL](https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneMKL)\n * [oneTBB](https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneTBB)\n * [oneVPL](https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneVPL)\n",
1313
"mdIntro3.4":"* [Publications](https://github.com/oneapi-src/oneAPI-samples/Publications/)\n * [Data Parallel C++](https://github.com/oneapi-src/oneAPI-samples/Publications/Data_Parallel_C%2B%2B)\n",
1414
"mdIntro3.5":"* [Tools](https://github.com/oneapi-src/oneAPI-samples/tree/master/Tools/)\n * [Advisor](https://github.com/oneapi-src/oneAPI-samples/tree/master/Tools/Advisor)\n * [Application Debugger](https://github.com/oneapi-src/oneAPI-samples/tree/master/Tools/ApplicationDebugger)\n * [Benchmark](https://github.com/oneapi-src/oneAPI-samples/tree/master/Tools/Benchmark)\n * [IoT Connections Tools](https://github.com/oneapi-src/oneAPI-samples/tree/master/Tools/IoTConnectionsTools)\n * [Migration](https://github.com/oneapi-src/oneAPI-samples/tree/master/Tools/Migration)\n * [Socwatch](https://github.com/oneapi-src/oneAPI-samples/tree/master/Tools/Socwatch)\n * [Trace](https://github.com/oneapi-src/oneAPI-samples/tree/master/Tools/Trace)\n * [UEFI debug](https://github.com/oneapi-src/oneAPI-samples/tree/master/Tools/UEFI%20debug)\n * [VTune Profiler](https://github.com/oneapi-src/oneAPI-samples/tree/master/Tools/VTuneProfiler)\n)", "mdIntro4":"To view an alphabetized list of all samples with descriptions by:",
15-
"mdIntro4.1":"- Samples in Alphabetical order w/ device target](https://github.com/oneapi-src/CODESAMPLESLIST.md/)",
16-
"mdIntro4.2":"- Samples by [Change History](https://github.com/oneapi-src/oneAPI-samples/CHANGELOGS.md)",
15+
"mdIntro4":"## Additional Resources\n- Samples in [Alphabetical order w/ device target](https://github.com/oneapi-src/CODESAMPLESLIST.md/)\n- Samples by [Change History](https://github.com/oneapi-src/oneAPI-samples/CHANGELOGS.md)",
16+
"mdIntro5":"\n\n## Known Issues or Limitations\n\n### On Windows Platform\n\n",
1717
"mdIntro5.1":"- If you are using Visual Studio 2019, Visual Studio 2019 version 16.4.0 or newer is required.",
1818
"mdIntro5.2":"- Windows support for the FPGA code samples is limited to the FPGA emulator and optimization reports. Compile targets for FPGA hardware are provided on Linux only. See any FPGA code sample for more details.",
1919
"mdIntro5.3":"- If you encounter a compilation error when building a sample program, such as the example error below, the directory path of the sample may be too long. The workaround is to move the sample to a temp directory.",
20-
"mdIntro5.4":"- Example error: *Error MSB6003 The specified task executable dpcpp.exe could not be run .......",
21-
"mdIntro6":"See [CONTRIBUTING wiki](https://github.com/oneapi-src/oneAPI-samples/blob/master/CONTRIBUTING.md) for more information.",
20+
"mdIntro5.4":" - Example error: *Error MSB6003 The specified task executable dpcpp.exe could not be run .......",
21+
"mdIntro6":"\n\n## Contributing\n\nSee [CONTRIBUTING wiki](https://github.com/oneapi-src/oneAPI-samples/blob/master/CONTRIBUTING.md) for more information.",
2222
"mdIntro7":"\n\n## New Code Samples\n\n|Version Introduced |Sample Name|Description|\n |-----------------------|-------------------------------------------|---------------|\n",
2323

24-
"mdDeviceTargetIntrop1": "## oneAPI Code Samples\n\n",
25-
"mdDeviceTargetIntrop2": "|Code Sample Name|Supported Intel&reg; Architecture(s)|Description|\n|-----------------------|----------------------|---------------------|\n",
24+
"mdCodeSamplesListIntrop1": "## oneAPI Code Samples\n\nThis Page is a complete list of onePI Code Samples, sorted by Alphabetical order",
25+
"mdCodeSamplesListIntrop2": "|Code Sample Name|Supported Intel&reg; Architecture(s)|Description|\n|-----------------------|----------------------|---------------------|\n",
2626

27-
"mdDeviceTargetFooter": "Report Generated on: ",
27+
"mdCodeSamplesListFooter": "Report Generated on: ",
2828

2929
"mdVersion": "## Version List of all samples\n\n sorted as found in directories\n\n|Code Sample/URL |Version|\n|-----------------------|------------------------|\n",
3030

31-
"mdChangeLogHeaderp1":"## oneAPI Code Sample Change log\n\nThis document shows the history of when a specific sample was introduced to the oneAPI ecosystem of Code Samples.<br>Current Samples Count: ",
31+
"mdChangeLogHeaderp1":"## oneAPI Code Sample Change log\n\nThis document shows the history of when a specific sample was introduced to the oneAPI ecosystem of Code Samples.",
3232
"mdChangeLogHeaderp2":"\n| Version|Code Sample Name|description|\n|-----------------------|------------------|-------------------------|\n"
3333

3434
}
Lines changed: 69 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1+
from datetime import date
2+
from collections import OrderedDict
13
from json.decoder import JSONDecodeError
24
from pathlib import Path
3-
from datetime import date
45
import os
56
import json
6-
from collections import OrderedDict
77
today = date.today()
8+
d = today.strftime("%B %d, %Y")
89
currentVersion = "2021.4.0"
910
fileName = "sample.json"
10-
fDeviceTargets = "CODESAMPLESLIST.md"
11+
fCodeSamplesLists = "CODESAMPLESLIST.md"
1112
fChangeLogs = "CHANGELOGS.md"
1213
freadme = "README.md"
1314
fguidVer = ".repo-tools\Docs_Automation\guids.json"
14-
absolute_path = os.getcwd()
15-
pathLength = len(absolute_path) #used to modify local path length, so only tree structure is left for crafting the url
1615
oneAPIURL = 'https://github.com/oneapi-src/oneAPI-samples/tree/master'
17-
d = today.strftime("%B %d, %Y")
1816
count = 0
1917

2018
def checkFileExists(checkFile):
@@ -23,37 +21,6 @@ def checkFileExists(checkFile):
2321
else:
2422
print("The " + checkFile + " file does not exist")
2523

26-
def createHeaders(dataContent):
27-
nf = open(fDeviceTargets,"w+")
28-
nf.write(dataContent['mdDeviceTargetIntrop1'] + dataContent['mdDeviceTargetIntrop2'])
29-
nf.close()
30-
nf = open(fChangeLogs,"w+")
31-
nf.write(dataContent['mdChangeLogHeaderp1'])
32-
nf.close()
33-
nf = open(freadme,"w+")
34-
nf.write("## Introduction\n\n")
35-
nf.write(dataContent['mdIntro1'] + "\n" +dataContent['mdIntro2'] + currentVersion + dataContent['mdIntro2.1'] + "\n ### Sample Details\n\n")
36-
nf.write(dataContent['mdIntro3'] + dataContent['mdIntro3.1']+dataContent['mdIntro3.2'] + dataContent['mdIntro3.3'] + dataContent['mdIntro3.4'] + dataContent['mdIntro3.5'])
37-
nf.write("\n" +dataContent['mdIntro4'] + "\n" +dataContent['mdIntro4.1'] + "\n" +dataContent['mdIntro4.2'])
38-
nf.write("\n\n### On Windows Platform\n\n" + dataContent['mdIntro5.1'] + "\n" + dataContent['mdIntro5.2'] + "\n" + dataContent['mdIntro5.3'] + "\n" + dataContent['mdIntro5.4'])
39-
nf.write("\n\n## Known Issues or Limitations\n\n## Contributing\n\n" + dataContent['mdIntro6'] + "\n\n" + dataContent['mdIntro7'])
40-
nf.close()
41-
42-
def createFooters(count):
43-
#setting up Device Targets
44-
nf = open(fDeviceTargets,"a")
45-
nf.write("Total Samples: " + str(count)+ "\n\n")
46-
nf.write(str(dataContent['mdDeviceTargetFooter']) + d)
47-
nf.write("\nThis doc was created on: " + d)
48-
nf.close()
49-
nf = open(freadme,"a+")
50-
nf.write(dataContent['mdLicense'])
51-
nf.write("\nThis doc was created on: " + d)
52-
nf.close()
53-
nf = open(fDeviceTargets,"a+")
54-
nf.write("\nThis doc was created on: " + d)
55-
nf.close()
56-
5724
def openJson(jsonFile): #creating a dictionary
5825
jsonData = open(jsonFile) #open the json file
5926
try:
@@ -62,113 +29,127 @@ def openJson(jsonFile): #creating a dictionary
6229
print(str(e)+': ' + jsonFile)
6330
return data
6431

65-
def readContent(): #readin in strings for use in document creation
32+
def readContent(): #reading in strings for use in document creation
6633
jsonFile = '.repo-tools\Docs_Automation\content.json'
6734
dataContent = openJson(jsonFile)
6835
return dataContent
69-
70-
def addVersion(dict_main, dict_version):# After walking thu directories we need to add version to dict_main
71-
for key in dict_version.keys():
72-
try:
73-
if (key in dict_main):
74-
dict_tmp=dict_version[key] #copy to dict_tmp if true
75-
ver=dict_tmp['ver']
76-
dict_main[key]['ver']=ver
77-
78-
except KeyError as e: #not working
79-
print(str(e) + ":No Match for guid: ")
8036

81-
def createChangeLog(count): #sorted but does not include version
82-
temp = dict_main.items()
83-
sorted_items = sorted(temp, key=lambda key_value: key_value[1]["name"], reverse=False) # sorts by name
84-
sorted_by_name = OrderedDict(sorted_items)
85-
86-
temp=dict_version.items()
87-
sorted_items = sorted(temp, key=lambda key_value: key_value[1]["ver"], reverse=True) # sorts by ver
88-
sorted_by_ver = OrderedDict(sorted_items)
89-
90-
nf = open(fChangeLogs,"a+")
91-
nf.write(str(count) + dataContent['mdChangeLogHeaderp2'])
92-
for key in sorted_by_name.keys():
37+
def createChangeLog(count,sorted_by_name,sorted_by_ver): #sorted but does not include version
38+
nf = open(fChangeLogs,"w+")
39+
nf.write(dataContent['mdChangeLogHeaderp1'])
40+
nf.write(dataContent['mdChangeLogHeaderp2'])
41+
42+
for key in sorted_by_ver.keys():
9343
description= str(sorted_by_name[key]['description'])
9444
url= sorted_by_name[key]['url']
9545
ver=sorted_by_ver[key]['ver']
9646
name=sorted_by_name[key]['name']
9747
cat=str(sorted_by_name[key]['categories'])
9848

49+
# Due to name issues, we need to fix the DPC** books chapter namesas its found and put it into the doc
9950
if (cat=="['Toolkit/Publication: Data Parallel C++']"):
100-
description=description.replace('*','<br>')
101-
name ="Pub: Data Parallel C++:](https://www.apress.com/9781484255735)" + "<br><br>[" + name
51+
name ="Pub: Data Parallel C++:](https://www.apress.com/9781484255735)<br>[" + name
52+
description=description.replace('*','')
53+
description=description.replace('fig_','<br>- Fig_')
54+
description="Collection of Code samples for the chapter"+description
55+
10256
nf.write("|" + ver + "|[" + name+ "](" + url + ")|" + description + "|\n")
57+
nf.write("Total Samples: " + str(count)+ "\n\n")
58+
nf.write(str(dataContent['mdCodeSamplesListFooter']) + d)
10359
nf.close()
60+
print("Change Log has been created")
10461

105-
def createTtargetedDevices():
62+
def createCodeSamplesList():
10663
temp = dict_main.items()
10764
sorted_items = sorted(temp, key=lambda key_value: key_value[1]["name"], reverse=False) # sorts by name
10865
sorted_by_name = OrderedDict(sorted_items)
10966
temp=sorted_by_name.items()
110-
nf = open(fDeviceTargets,"a+")
111-
67+
nf = open(fCodeSamplesLists,"w+")
68+
nf.write(dataContent['mdCodeSamplesListIntrop1'] + "\n\n" + dataContent['mdCodeSamplesListIntrop2'])
11269
for key in sorted_by_name.keys():
11370
description= str(sorted_by_name[key]['description'])
11471
url= sorted_by_name[key]['url']
11572
name=sorted_by_name[key]['name']
11673
target= str(sorted_by_name[key]['targetDevice'])
11774
cat=str(sorted_by_name[key]['categories'])
11875
if (cat=="""['Toolkit/Publication: Data Parallel C++']"""):
119-
description=description.replace('*','<br>')
120-
name ="Pub: Data Parallel C++:](https://www.apress.com/9781484255735)" + "<br><br>[" + name
76+
description=description.replace('*','')
77+
description=description.replace('fig_','<br>- Fig_')
78+
description="Collection of Code samples for the chapter"+description
79+
name ="Pub: Data Parallel C++:](https://www.apress.com/9781484255735)<br>[" + name
12180
nf.write("|[" + name+ "](" + url + ")|" + target + "|" + description + "|\n")
81+
82+
nf.write("Total Samples: " + str(count)+ "\n\n")
83+
nf.write(str(dataContent['mdCodeSamplesListFooter']) + d)
84+
nf.write("Total Samples: " + str(count)+ "\n\n")
12285
nf.close()
86+
print("Code Samples List has been created")
12387

124-
def createReadme():
125-
temp = dict_main.items()
126-
sorted_items = sorted(temp, key=lambda key_value: key_value[1]["name"], reverse=False) # sorts by name
127-
sorted_by_name = OrderedDict(sorted_items)
128-
nf = open(freadme,"a+")
129-
88+
def createReadme(sorted_by_name, sorted_by_ver):
89+
nf = open(freadme,"w+")
90+
nf.write("## Introduction\n\n")
91+
nf.write(dataContent['mdIntro1'] + "\n" +dataContent['mdIntro2'] + currentVersion + dataContent['mdIntro2.1'] + "\n ### Sample Details\n\n")
92+
nf.write(dataContent['mdIntro3'] + dataContent['mdIntro3.1']+dataContent['mdIntro3.2'] + dataContent['mdIntro3.3'] + dataContent['mdIntro3.4'] + dataContent['mdIntro3.5'])
93+
nf.write(dataContent['mdIntro5'] + dataContent['mdIntro5.1'] + "\n" + dataContent['mdIntro5.2'] + "\n" + dataContent['mdIntro5.3'] + "\n" + dataContent['mdIntro5.4'])
94+
nf.write("\n\n" +dataContent['mdIntro4'])
95+
nf.write(dataContent['mdIntro6'] + "\n\n" + dataContent['mdIntro7'])
96+
13097
for key in sorted_by_name.keys():
13198
description= str(sorted_by_name[key]['description'])
13299
url= sorted_by_name[key]['url']
133-
ver=sorted_by_name[key]['ver']
100+
ver=sorted_by_ver[key]['ver']
134101
name=sorted_by_name[key]['name']
135102
cat=str(sorted_by_name[key]['categories'])
136103
if (cat=="""['Toolkit/Publication: Data Parallel C++']"""):
137-
name ="Pub: Data Parallel C++:](https://www.apress.com/9781484255735)" + "\n\n[" + name
138-
description=description.replace('*','<br>')
104+
name ="Pub: Data Parallel C++:](https://www.apress.com/9781484255735)<br>[" + name
105+
description=description.replace('*','')
106+
description=description.replace('fig_','<br>- Fig_')
107+
description="Collection of Code samples for the chapter"+description
139108
if (ver==currentVersion):
140109
nf.write("|" + ver + "|[" + name+ "](" + url + ")|" + description + "|\n")
110+
nf.write("\nTotal Samples: " + str(count)+ "\n\n")
111+
nf.write(dataContent['mdLicense'])
112+
nf.write("\n\n")
113+
nf.write(str(dataContent['mdCodeSamplesListFooter']) + d)
141114
nf.close()
142-
115+
print("Readme has been created")
116+
143117
#main
144-
checkFileExists(fDeviceTargets) #Cleaning up from previous run
118+
checkFileExists(fCodeSamplesLists) #Cleaning up from previous run
145119
checkFileExists(fChangeLogs) #Cleaning up from previous run
146120
checkFileExists(freadme) #Cleaning up from previous run
147121
dataContent = readContent() #read json for data used in creating document header and footers
148-
createHeaders(dataContent) #create headers for the various documents being generated
149122

150123
dict_main={}
151124
dict_version = openJson(fguidVer)
152125

153-
for subdir, dirs, files in os.walk('..\\'):
126+
for subdir, dirs, files in os.walk('..\\'): # walk through samples repo looking for samples.json, if found add data to dict_main
154127
for file in files:
155128
if (file == fileName):
156129
f = os.path.join(subdir, file)
130+
data = openJson(f)
131+
dict_main[data['guid']]=data
157132
# build url
158133
fp = os.path.join(subdir)
159134
fp = fp.replace('\\','/') #char replace \ for /
160135
fullURL=oneAPIURL+(str(fp)[17:]) # removed first 17 characters of the path, which is always "../oneAPI-samples/"
161136
#end build url
162-
data = openJson(f)
163-
dict_main[data['guid']]=data
164137
dict_main[data['guid']]['url'] = fullURL
165138
count = count+1
139+
140+
temp = dict_main.items()
141+
sorted_by_name = OrderedDict(sorted(temp, key=lambda key_value: key_value[1]["name"], reverse=False))
142+
143+
temp=dict_version.items()
144+
sorted_by_ver = OrderedDict(sorted(temp, key=lambda key_value: key_value[1]["ver"], reverse=True))
166145
# Future - add a search for license file and if none, show a warning
167146
# Future - if no sample.json is present then show a warning
168147
# future - if no readme.md is present then show a warning
169-
addVersion(dict_main,dict_version)
170-
createChangeLog(count)
171-
createTtargetedDevices()
172-
createReadme()
173-
createFooters(count)
148+
# future - Check dict_main vs dict_version for guid present if not then need to add
149+
# furure - check dict_version vs dict_main for guid present if not then need to allow if new sample hasnt been uploaded
150+
151+
createChangeLog(count,sorted_by_name,sorted_by_ver)
152+
createCodeSamplesList()
153+
createReadme(sorted_by_name,sorted_by_ver)
154+
174155
print("Finished")

.repo-tools/Docs_Automation/guids.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -689,12 +689,6 @@
689689
"name": "Particle Diffusion",
690690
"notes": "-"
691691
},
692-
"668A3FF9-12C3-4559-8AF4-54B6792122D3": {
693-
"guid": "668A3FF9-12C3-4559-8AF4-54B6792122D3",
694-
"ver": "2021.1.Gold",
695-
"name": "System Debug",
696-
"notes": "-"
697-
},
698692
"314B4C1D-07A0-4527-A9FA-9F87ED9622D7": {
699693
"guid": "314B4C1D-07A0-4527-A9FA-9F87ED9622D7",
700694
"ver": "2021.2.1",
@@ -713,13 +707,6 @@
713707
"name": "Fourier Correlation",
714708
"notes": "-"
715709
},
716-
"7909FAE1-D3D4-4E97-A963-14A884F33495": {
717-
"guid": "7909FAE1-D3D4-4E97-A963-14A884F33495",
718-
"ver": "2021.2.1",
719-
"name": "Max Concurrency",
720-
"notes": "Removed in 2021.4",
721-
"removed": "x"
722-
},
723710
"8401B5F5-6F09-4727-A080-684C57104CAF": {
724711
"guid": "8401B5F5-6F09-4727-A080-684C57104CAF",
725712
"ver": "2021.2.1",
@@ -919,11 +906,6 @@
919906
"ver": "2021.1.Gold",
920907
"name": "Tutorials"
921908
},
922-
"dc8c1c92-1c2a-4edf-abbd-6c35dfab256a": {
923-
"guid": "dc8c1c92-1c2a-4edf-abbd-6c35dfab256a",
924-
"ver": "2021.4.0",
925-
"name": "VisualComputing tutorial"
926-
},
927909
"748eb906-309f-469b-95c9-5258006c7587": {
928910
"guid": "748eb906-309f-469b-95c9-5258006c7587",
929911
"ver": "2021.1.Gold",

0 commit comments

Comments
 (0)