Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
0d9870dd
Commit
0d9870dd
authored
Jun 01, 2016
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement website update script
parent
5e70843a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
58 deletions
+61
-58
support/update-website.py
support/update-website.py
+61
-58
No files found.
support/update-website.py
View file @
0d9870dd
#!/usr/bin/env python
#!/usr/bin/env python
import
os
,
re
,
shutil
,
sys
,
tempfile
import
os
,
re
,
shutil
,
sys
from
subprocess
import
check_call
from
subprocess
import
check_call
class
Git
:
class
Git
:
...
@@ -22,65 +22,68 @@ class Git:
...
@@ -22,65 +22,68 @@ class Git:
def
reset
(
self
,
*
args
):
def
reset
(
self
,
*
args
):
return
self
.
call
(
'reset'
,
args
,
cwd
=
self
.
dir
)
return
self
.
call
(
'reset'
,
args
,
cwd
=
self
.
dir
)
# Create build environment.
def
pull
(
self
,
*
args
):
return
self
.
call
(
'pull'
,
args
,
cwd
=
self
.
dir
)
def
update
(
self
,
*
args
):
if
not
os
.
path
.
exists
(
self
.
dir
):
self
.
clone
(
*
args
)
# Import the documentation build module.
fmt_dir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
fmt_dir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
fmt_dir
,
'doc'
))
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
fmt_dir
,
'doc'
))
import
build
work_dir
=
'build'
# Virtualenv and repos are cached to speed up builds.
build
.
create_build_env
(
os
.
path
.
join
(
work_dir
,
'virtualenv'
))
work_dir
=
tempfile
.
mkdtemp
(
'fmt'
)
fmt_repo
=
Git
(
os
.
path
.
join
(
work_dir
,
'fmt'
))
try
:
fmt_repo
.
update
(
'git@github.com:fmtlib/fmt'
)
import
build
# The virtualenv is stored in ~/.cache/fmt/virtualenv and reused to speed
# up builds.
build
.
create_build_env
(
os
.
path
.
join
(
os
.
path
.
expanduser
(
'~'
),
'.cache'
,
'fmt'
,
'virtualenv'
))
fmt_repo
=
Git
(
os
.
path
.
join
(
work_dir
,
'fmt'
))
doc_repo
=
Git
(
os
.
path
.
join
(
work_dir
,
'fmtlib.github.io'
))
fmt_repo
.
clone
(
'git@github.com:fmtlib/fmt'
)
doc_repo
.
update
(
'git@github.com:fmtlib/fmtlib.github.io'
)
doc_repo
=
Git
(
'fmtlib.github.io'
)
doc_repo
.
clone
(
'git@github.com:fmtlib/fmtlib.github.io'
)
for
version
in
[
'1.0.0'
]:
#, '1.1.0', '2.0.0', '3.0.0']:
for
version
in
[
'1.0.0'
]:
#, '1.1.0', '2.0.0', '3.0.0']:
fmt_repo
.
clean
(
'-f'
,
'-d'
)
fmt_repo
.
clean
(
'-f'
,
'-d'
)
fmt_repo
.
reset
(
'--hard'
)
fmt_repo
.
reset
(
'--hard'
)
fmt_repo
.
checkout
(
version
)
fmt_repo
.
checkout
(
version
)
target_doc_dir
=
os
.
path
.
join
(
fmt_repo
.
dir
,
'doc'
)
target_doc_dir
=
os
.
path
.
join
(
fmt_repo
.
dir
,
'doc'
)
# Remove the old theme.
# Remove the old theme.
for
entry
in
os
.
listdir
(
target_doc_dir
):
for
entry
in
os
.
listdir
(
target_doc_dir
):
path
=
os
.
path
.
join
(
target_doc_dir
,
entry
)
path
=
os
.
path
.
join
(
target_doc_dir
,
entry
)
if
os
.
path
.
isdir
(
path
):
if
os
.
path
.
isdir
(
path
):
shutil
.
rmtree
(
path
)
shutil
.
rmtree
(
path
)
# Copy the new theme.
# Copy the new theme.
for
entry
in
[
'_static'
,
'_templates'
,
'basic-bootstrap'
,
'bootstrap'
,
for
entry
in
[
'_static'
,
'_templates'
,
'basic-bootstrap'
,
'bootstrap'
,
'conf.py'
,
'fmt.less'
]:
'conf.py'
,
'fmt.less'
]:
src
=
os
.
path
.
join
(
fmt_dir
,
'doc'
,
entry
)
src
=
os
.
path
.
join
(
fmt_dir
,
'doc'
,
entry
)
dst
=
os
.
path
.
join
(
target_doc_dir
,
entry
)
dst
=
os
.
path
.
join
(
target_doc_dir
,
entry
)
copy
=
shutil
.
copytree
if
os
.
path
.
isdir
(
src
)
else
shutil
.
copyfile
copy
=
shutil
.
copytree
if
os
.
path
.
isdir
(
src
)
else
shutil
.
copyfile
copy
(
src
,
dst
)
copy
(
src
,
dst
)
# Rename index to contents.
# TODO: update links in navbar
contents
=
os
.
path
.
join
(
target_doc_dir
,
'contents.rst'
)
# Rename index to contents.
if
not
os
.
path
.
exists
(
contents
):
contents
=
os
.
path
.
join
(
target_doc_dir
,
'contents.rst'
)
os
.
rename
(
os
.
path
.
join
(
target_doc_dir
,
'index.rst'
),
contents
)
if
not
os
.
path
.
exists
(
contents
):
# Fix issues in reference.rst.
os
.
rename
(
os
.
path
.
join
(
target_doc_dir
,
'index.rst'
),
contents
)
reference
=
os
.
path
.
join
(
target_doc_dir
,
'reference.rst'
)
# Fix issues in reference.rst.
if
os
.
path
.
exists
(
reference
):
reference
=
os
.
path
.
join
(
target_doc_dir
,
'reference.rst'
)
with
open
(
reference
)
as
f
:
if
os
.
path
.
exists
(
reference
):
data
=
f
.
read
()
with
open
(
reference
)
as
f
:
data
=
data
.
replace
(
'std::ostream &'
,
'std::ostream&'
)
data
=
f
.
read
()
data
=
re
.
sub
(
'doxygenfunction.. (bin|oct|hexu|hex)'
,
data
=
data
.
replace
(
'std::ostream &'
,
'std::ostream&'
)
r'doxygenfunction:: \1(int)'
,
data
)
data
=
re
.
sub
(
r'doxygenfunction.. (bin|oct|hexu|hex)'
,
with
open
(
reference
,
'w'
)
as
f
:
r'doxygenfunction:: \1(int)'
,
data
)
f
.
write
(
data
)
with
open
(
reference
,
'w'
)
as
f
:
# Build the docs.
f
.
write
(
data
)
build
.
build_docs
(
version
,
doc_dir
=
target_doc_dir
,
include_dir
=
fmt_repo
.
dir
,
# Build the docs.
work_dir
=
work_dir
)
html_dir
=
build
.
build_docs
(
version
,
doc_dir
=
target_doc_dir
,
# Create symlinks for older versions.
include_dir
=
fmt_repo
.
dir
,
work_dir
=
work_dir
)
for
link
,
target
in
{
'index'
:
'contents'
,
'api'
:
'reference'
}.
items
():
# Create symlinks for older versions.
os
.
symlink
(
target
+
'.html'
,
os
.
path
.
join
(
'html'
,
link
)
+
'.html'
)
for
link
,
target
in
{
'index'
:
'contents'
,
'api'
:
'reference'
}.
items
():
# Copy docs to the website.
os
.
symlink
(
target
+
'.html'
,
os
.
path
.
join
(
html_dir
,
link
)
+
'.html'
)
version_doc_dir
=
os
.
path
.
join
(
doc_repo
.
dir
,
version
)
# Copy docs to the website.
shutil
.
rmtree
(
version_doc_dir
)
version_doc_dir
=
os
.
path
.
join
(
doc_repo
.
dir
,
version
)
shutil
.
move
(
'html'
,
version_doc_dir
)
shutil
.
rmtree
(
version_doc_dir
)
# TODO: update links in navbar
shutil
.
move
(
html_dir
,
version_doc_dir
)
# TODO: remove doc repo
except
:
shutil
.
rmtree
(
work_dir
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment