31 """Script for branching Google Test/Mock wiki pages for a new version.
34 release_docs.py NEW_RELEASE_VERSION
36 Google Test and Google Mock's external user documentation is in
37 interlinked wiki files. When we release a new version of
38 Google Test or Google Mock, we need to branch the wiki files
39 such that users of a specific version of Google Test/Mock can
40 look up documenation relevant for that version. This script
41 automates that process by:
43 - branching the current wiki pages (which document the
44 behavior of the SVN trunk head) to pages for the specified
45 version (e.g. branching FAQ.wiki to V2_6_FAQ.wiki when
46 NEW_RELEASE_VERSION is 2.6);
47 - updating the links in the branched files to point to the branched
48 version (e.g. a link in V2_6_FAQ.wiki that pointed to
49 Primer.wiki#Anchor will now point to V2_6_Primer.wiki#Anchor).
51 NOTE: NEW_RELEASE_VERSION must be a NEW version number for
52 which the wiki pages don't yet exist; otherwise you'll get SVN
53 errors like "svn: Path 'V1_7_PumpManual.wiki' is not a
54 directory" when running the script.
57 $ cd PATH/TO/GTEST_SVN_WORKSPACE/trunk
58 $ scripts/release_docs.py 2.6 # create wiki pages for v2.6
59 $ svn status # verify the file list
60 $ svn diff # verify the file contents
61 $ svn commit -m "release wiki pages for v2.6"
64 __author__ =
'wan@google.com (Zhanyong Wan)'
74 GTEST_UNVERSIONED_WIKIS = [
'DevGuide.wiki']
75 GMOCK_UNVERSIONED_WIKIS = [
83 """Removes the .wiki suffix (if any) from the given filename."""
85 return (wiki_filename[:-len(
'.wiki')]
if wiki_filename.endswith(
'.wiki')
94 if self.
project not in (
'googletest',
'googlemock'):
95 sys.exit(
'This script must be run in a gtest or gmock SVN workspace.')
114 r'(\[|/wiki/)(%s)([ #])' %
'|'.
join(page_names))
118 """Returns a list of .wiki file names that need to be branched."""
120 unversioned_wikis = (GTEST_UNVERSIONED_WIKIS
if self.
project ==
'googletest'
121 else GMOCK_UNVERSIONED_WIKIS)
122 return [f
for f
in os.listdir(self.
wiki_dir)
123 if (f.endswith(
'.wiki')
and
124 not re.match(
r'^V\d', f)
and
125 f
not in unversioned_wikis)]
128 """Branches the .wiki files needed to be branched."""
140 source_file = os.path.join(self.
wiki_dir, f)
142 print 'Updating links in %s.' % (versioned_file,)
143 text =
file(source_file,
'r').read()
144 new_text = self.search_for_re.sub(self.replace_with, text)
145 file(versioned_file, 'w').
write(new_text)
149 if len(sys.argv) != 2:
153 brancher.BranchFiles()
154 brancher.UpdateLinksInBranchedFiles()
157 if __name__ ==
'__main__':