Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit 87032fb

Browse files
committed
support extracting comments
1 parent eae3804 commit 87032fb

File tree

1 file changed

+25
-6
lines changed
  • ToolsForMaintainersOfTheProjectTemplate/notepad_hfiles_synchronizer

1 file changed

+25
-6
lines changed

ToolsForMaintainersOfTheProjectTemplate/notepad_hfiles_synchronizer/cs.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def isEmptyLine(self):
1313
return self.parsedContent == None and self.comment == ""
1414

1515
def isComment(self):
16-
return self.content == "" and self.comment != ""
16+
return self.comment != ""
1717

1818
def isDefinition(self):
1919
return self.parsedContent != None
@@ -41,24 +41,43 @@ def parseFile(name):
4141
allLines.append(parseLine(line))
4242
return allLines
4343

44-
def printFile(name):
44+
45+
def getComments(j, lines):
46+
out = []
47+
anyComment = False
48+
while j < len(lines) and lines[j].isComment():
49+
if len(out) == 0:
50+
out.append(" /// <summary>")
51+
out.append(" /%s" %(lines[j].comment))
52+
j = j + 1
53+
if len(out) > 0:
54+
out.append(" /// </summary>")
55+
return out
56+
57+
58+
def printFile(name, addComments):
4559
out = []
4660
lines = parseFile(name)
4761

4862
for i in range(0, len(lines)):
63+
# blank lines
4964
if not lines[i].isDefinition():
5065
if i+1 >= len(lines) or lines[i+1].isDefinition():
5166
out.append("")
67+
# definitions
5268
elif lines[i].isDefinition():
69+
if addComments == True:
70+
out.extend(getComments(i+1, lines))
5371
value = lines[i].parsedContent.group("value")
5472
value = value.replace("WM_USER","Constants.WM_USER")
5573
value = value.replace("NPPMSG","Constants.NPPMSG")
56-
out.append (" %s = %s," %(lines[i].parsedContent.group("name"), value))
74+
name = lines[i].parsedContent.group("name")
75+
out.append (" %s = %s," %(name, value))
5776
return out
5877

5978
if __name__ == "__main__":
60-
preffile = printFile("../../../notepad-plus-plus/PowerEditor/src/WinControls/Preference/preference_rc.h")
79+
preffile = printFile("../../../notepad-plus-plus/PowerEditor/src/WinControls/Preference/preference_rc.h", False)
6180
Regenerate("../../Visual Studio Project Template C#/PluginInfrastructure/Preference_h.cs", "/* ", preffile)
6281

63-
resourcefile = printFile("../../../notepad-plus-plus/PowerEditor/src/resource.h")
64-
Regenerate("../../Visual Studio Project Template C#/PluginInfrastructure/resource_h.cs", "/* ", resourcefile)
82+
resourcefile = printFile("../../../notepad-plus-plus/PowerEditor/src/resource.h", False)
83+
Regenerate("../../Visual Studio Project Template C#/PluginInfrastructure/Resource_h.cs", "/* ", resourcefile)

0 commit comments

Comments
 (0)