public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/sphinx-final)] FIXME: sphinx: add update_web_docs_git.py script
@ 2022-11-08 11:24 Martin Liska
0 siblings, 0 replies; 8+ messages in thread
From: Martin Liska @ 2022-11-08 11:24 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e07a653bea7d4b981aa9fb8748a0828c464f1724
commit e07a653bea7d4b981aa9fb8748a0828c464f1724
Author: Martin Liska <mliska@suse.cz>
Date: Mon Nov 7 22:07:47 2022 +0100
FIXME: sphinx: add update_web_docs_git.py script
maintainer-scripts/ChangeLog:
* update_web_docs_git.py: New file.
Diff:
---
maintainer-scripts/update_web_docs_git.py | 81 +++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/maintainer-scripts/update_web_docs_git.py b/maintainer-scripts/update_web_docs_git.py
new file mode 100755
index 00000000000..a02d0d1e6b0
--- /dev/null
+++ b/maintainer-scripts/update_web_docs_git.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+
+# Generate documentation from Sphinx files.
+
+import argparse
+import os
+import shutil
+import subprocess
+import tempfile
+from pathlib import Path
+
+GITROOT = '/git/gcc.git'
+BUGURL = 'https://gcc.gnu.org/bugs/'
+
+parser = argparse.ArgumentParser(description='Update web documentation.')
+parser.add_argument('output_folder', help='Output folder')
+parser.add_argument('--gitrepo', help=f'Git repository (default: {GITROOT})',
+ default=GITROOT)
+parser.add_argument('--sphinx-build', help='Path to sphinx-build binary')
+args = parser.parse_args()
+
+
+def find_configs():
+ for root, _, files in os.walk('.'):
+ for f in files:
+ full = os.path.join(root, f)
+ if f == 'conf.py':
+ # find name of the documentation
+ lines = open(full).read().splitlines()
+ docname = None
+ for line in lines:
+ if line.startswith('name = '):
+ docname = line.split()[-1].strip("'")
+ break
+ assert docname
+ yield (Path(root).resolve(), docname)
+
+
+with tempfile.TemporaryDirectory() as folder:
+ print(f'Using {folder} as temporary directory')
+ os.chdir(folder)
+ subprocess.check_output(f'git clone {args.gitrepo} --depth=1', shell=True)
+ # TODO: remove
+ os.chdir('gcc')
+ cmd = 'git fetch origin refs/users/marxin/heads/sphinx-final --depth=1'
+ subprocess.check_output(cmd, shell=True)
+ subprocess.check_output('git checkout FETCH_HEAD', shell=True)
+ configs = list(find_configs())
+
+ # Prepare folders
+ output = Path(args.output_folder)
+ if not output.exists():
+ output.mkdir()
+
+ temp = Path('tmp').resolve()
+ temp.mkdir()
+
+ # Prepare default env. variables
+ childenv = os.environ.copy()
+ childenv['BUGURL'] = BUGURL
+
+ # Build and copy the documentation
+ for config_folder, docname in sorted(configs):
+ print('=== BUILDING:', config_folder, docname, '===')
+
+ # Build HTML
+ cmd = f'make -C doc html SOURCEDIR={config_folder} BUILDDIR={temp}/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ os.unlink(f'{temp}/{docname}/html/.buildinfo')
+ shutil.copytree(f'{temp}/{docname}/html', f'{output}/{docname}',
+ dirs_exist_ok=True)
+
+ # Build PDF
+ cmd = f'make -C doc latexpdf SOURCEDIR={config_folder} BUILDDIR={temp}/pdf/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ shutil.copyfile(f'{temp}/pdf/{docname}/latex/{docname}.pdf',
+ f'{output}/{docname}.pdf')
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gcc(refs/users/marxin/heads/sphinx-final)] FIXME: sphinx: add update_web_docs_git.py script
@ 2022-11-08 14:54 Martin Liska
0 siblings, 0 replies; 8+ messages in thread
From: Martin Liska @ 2022-11-08 14:54 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:0028ec9639619bdbcfad28d6aa2d9650cb8f6999
commit 0028ec9639619bdbcfad28d6aa2d9650cb8f6999
Author: Martin Liska <mliska@suse.cz>
Date: Mon Nov 7 22:07:47 2022 +0100
FIXME: sphinx: add update_web_docs_git.py script
maintainer-scripts/ChangeLog:
* update_web_docs_git.py: New file.
Diff:
---
maintainer-scripts/update_web_docs_git.py | 81 +++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/maintainer-scripts/update_web_docs_git.py b/maintainer-scripts/update_web_docs_git.py
new file mode 100755
index 00000000000..a02d0d1e6b0
--- /dev/null
+++ b/maintainer-scripts/update_web_docs_git.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+
+# Generate documentation from Sphinx files.
+
+import argparse
+import os
+import shutil
+import subprocess
+import tempfile
+from pathlib import Path
+
+GITROOT = '/git/gcc.git'
+BUGURL = 'https://gcc.gnu.org/bugs/'
+
+parser = argparse.ArgumentParser(description='Update web documentation.')
+parser.add_argument('output_folder', help='Output folder')
+parser.add_argument('--gitrepo', help=f'Git repository (default: {GITROOT})',
+ default=GITROOT)
+parser.add_argument('--sphinx-build', help='Path to sphinx-build binary')
+args = parser.parse_args()
+
+
+def find_configs():
+ for root, _, files in os.walk('.'):
+ for f in files:
+ full = os.path.join(root, f)
+ if f == 'conf.py':
+ # find name of the documentation
+ lines = open(full).read().splitlines()
+ docname = None
+ for line in lines:
+ if line.startswith('name = '):
+ docname = line.split()[-1].strip("'")
+ break
+ assert docname
+ yield (Path(root).resolve(), docname)
+
+
+with tempfile.TemporaryDirectory() as folder:
+ print(f'Using {folder} as temporary directory')
+ os.chdir(folder)
+ subprocess.check_output(f'git clone {args.gitrepo} --depth=1', shell=True)
+ # TODO: remove
+ os.chdir('gcc')
+ cmd = 'git fetch origin refs/users/marxin/heads/sphinx-final --depth=1'
+ subprocess.check_output(cmd, shell=True)
+ subprocess.check_output('git checkout FETCH_HEAD', shell=True)
+ configs = list(find_configs())
+
+ # Prepare folders
+ output = Path(args.output_folder)
+ if not output.exists():
+ output.mkdir()
+
+ temp = Path('tmp').resolve()
+ temp.mkdir()
+
+ # Prepare default env. variables
+ childenv = os.environ.copy()
+ childenv['BUGURL'] = BUGURL
+
+ # Build and copy the documentation
+ for config_folder, docname in sorted(configs):
+ print('=== BUILDING:', config_folder, docname, '===')
+
+ # Build HTML
+ cmd = f'make -C doc html SOURCEDIR={config_folder} BUILDDIR={temp}/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ os.unlink(f'{temp}/{docname}/html/.buildinfo')
+ shutil.copytree(f'{temp}/{docname}/html', f'{output}/{docname}',
+ dirs_exist_ok=True)
+
+ # Build PDF
+ cmd = f'make -C doc latexpdf SOURCEDIR={config_folder} BUILDDIR={temp}/pdf/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ shutil.copyfile(f'{temp}/pdf/{docname}/latex/{docname}.pdf',
+ f'{output}/{docname}.pdf')
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gcc(refs/users/marxin/heads/sphinx-final)] FIXME: sphinx: add update_web_docs_git.py script
@ 2022-11-08 14:43 Martin Liska
0 siblings, 0 replies; 8+ messages in thread
From: Martin Liska @ 2022-11-08 14:43 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8b33b1d2a597ef28d61c2eb58e1c991d062025a2
commit 8b33b1d2a597ef28d61c2eb58e1c991d062025a2
Author: Martin Liska <mliska@suse.cz>
Date: Mon Nov 7 22:07:47 2022 +0100
FIXME: sphinx: add update_web_docs_git.py script
maintainer-scripts/ChangeLog:
* update_web_docs_git.py: New file.
Diff:
---
maintainer-scripts/update_web_docs_git.py | 81 +++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/maintainer-scripts/update_web_docs_git.py b/maintainer-scripts/update_web_docs_git.py
new file mode 100755
index 00000000000..a02d0d1e6b0
--- /dev/null
+++ b/maintainer-scripts/update_web_docs_git.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+
+# Generate documentation from Sphinx files.
+
+import argparse
+import os
+import shutil
+import subprocess
+import tempfile
+from pathlib import Path
+
+GITROOT = '/git/gcc.git'
+BUGURL = 'https://gcc.gnu.org/bugs/'
+
+parser = argparse.ArgumentParser(description='Update web documentation.')
+parser.add_argument('output_folder', help='Output folder')
+parser.add_argument('--gitrepo', help=f'Git repository (default: {GITROOT})',
+ default=GITROOT)
+parser.add_argument('--sphinx-build', help='Path to sphinx-build binary')
+args = parser.parse_args()
+
+
+def find_configs():
+ for root, _, files in os.walk('.'):
+ for f in files:
+ full = os.path.join(root, f)
+ if f == 'conf.py':
+ # find name of the documentation
+ lines = open(full).read().splitlines()
+ docname = None
+ for line in lines:
+ if line.startswith('name = '):
+ docname = line.split()[-1].strip("'")
+ break
+ assert docname
+ yield (Path(root).resolve(), docname)
+
+
+with tempfile.TemporaryDirectory() as folder:
+ print(f'Using {folder} as temporary directory')
+ os.chdir(folder)
+ subprocess.check_output(f'git clone {args.gitrepo} --depth=1', shell=True)
+ # TODO: remove
+ os.chdir('gcc')
+ cmd = 'git fetch origin refs/users/marxin/heads/sphinx-final --depth=1'
+ subprocess.check_output(cmd, shell=True)
+ subprocess.check_output('git checkout FETCH_HEAD', shell=True)
+ configs = list(find_configs())
+
+ # Prepare folders
+ output = Path(args.output_folder)
+ if not output.exists():
+ output.mkdir()
+
+ temp = Path('tmp').resolve()
+ temp.mkdir()
+
+ # Prepare default env. variables
+ childenv = os.environ.copy()
+ childenv['BUGURL'] = BUGURL
+
+ # Build and copy the documentation
+ for config_folder, docname in sorted(configs):
+ print('=== BUILDING:', config_folder, docname, '===')
+
+ # Build HTML
+ cmd = f'make -C doc html SOURCEDIR={config_folder} BUILDDIR={temp}/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ os.unlink(f'{temp}/{docname}/html/.buildinfo')
+ shutil.copytree(f'{temp}/{docname}/html', f'{output}/{docname}',
+ dirs_exist_ok=True)
+
+ # Build PDF
+ cmd = f'make -C doc latexpdf SOURCEDIR={config_folder} BUILDDIR={temp}/pdf/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ shutil.copyfile(f'{temp}/pdf/{docname}/latex/{docname}.pdf',
+ f'{output}/{docname}.pdf')
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gcc(refs/users/marxin/heads/sphinx-final)] FIXME: sphinx: add update_web_docs_git.py script
@ 2022-11-08 14:36 Martin Liska
0 siblings, 0 replies; 8+ messages in thread
From: Martin Liska @ 2022-11-08 14:36 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:b509732f0a01b937a9b6be0e7ffec3300a4f2f5b
commit b509732f0a01b937a9b6be0e7ffec3300a4f2f5b
Author: Martin Liska <mliska@suse.cz>
Date: Mon Nov 7 22:07:47 2022 +0100
FIXME: sphinx: add update_web_docs_git.py script
maintainer-scripts/ChangeLog:
* update_web_docs_git.py: New file.
Diff:
---
maintainer-scripts/update_web_docs_git.py | 81 +++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/maintainer-scripts/update_web_docs_git.py b/maintainer-scripts/update_web_docs_git.py
new file mode 100755
index 00000000000..a02d0d1e6b0
--- /dev/null
+++ b/maintainer-scripts/update_web_docs_git.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+
+# Generate documentation from Sphinx files.
+
+import argparse
+import os
+import shutil
+import subprocess
+import tempfile
+from pathlib import Path
+
+GITROOT = '/git/gcc.git'
+BUGURL = 'https://gcc.gnu.org/bugs/'
+
+parser = argparse.ArgumentParser(description='Update web documentation.')
+parser.add_argument('output_folder', help='Output folder')
+parser.add_argument('--gitrepo', help=f'Git repository (default: {GITROOT})',
+ default=GITROOT)
+parser.add_argument('--sphinx-build', help='Path to sphinx-build binary')
+args = parser.parse_args()
+
+
+def find_configs():
+ for root, _, files in os.walk('.'):
+ for f in files:
+ full = os.path.join(root, f)
+ if f == 'conf.py':
+ # find name of the documentation
+ lines = open(full).read().splitlines()
+ docname = None
+ for line in lines:
+ if line.startswith('name = '):
+ docname = line.split()[-1].strip("'")
+ break
+ assert docname
+ yield (Path(root).resolve(), docname)
+
+
+with tempfile.TemporaryDirectory() as folder:
+ print(f'Using {folder} as temporary directory')
+ os.chdir(folder)
+ subprocess.check_output(f'git clone {args.gitrepo} --depth=1', shell=True)
+ # TODO: remove
+ os.chdir('gcc')
+ cmd = 'git fetch origin refs/users/marxin/heads/sphinx-final --depth=1'
+ subprocess.check_output(cmd, shell=True)
+ subprocess.check_output('git checkout FETCH_HEAD', shell=True)
+ configs = list(find_configs())
+
+ # Prepare folders
+ output = Path(args.output_folder)
+ if not output.exists():
+ output.mkdir()
+
+ temp = Path('tmp').resolve()
+ temp.mkdir()
+
+ # Prepare default env. variables
+ childenv = os.environ.copy()
+ childenv['BUGURL'] = BUGURL
+
+ # Build and copy the documentation
+ for config_folder, docname in sorted(configs):
+ print('=== BUILDING:', config_folder, docname, '===')
+
+ # Build HTML
+ cmd = f'make -C doc html SOURCEDIR={config_folder} BUILDDIR={temp}/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ os.unlink(f'{temp}/{docname}/html/.buildinfo')
+ shutil.copytree(f'{temp}/{docname}/html', f'{output}/{docname}',
+ dirs_exist_ok=True)
+
+ # Build PDF
+ cmd = f'make -C doc latexpdf SOURCEDIR={config_folder} BUILDDIR={temp}/pdf/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ shutil.copyfile(f'{temp}/pdf/{docname}/latex/{docname}.pdf',
+ f'{output}/{docname}.pdf')
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gcc(refs/users/marxin/heads/sphinx-final)] FIXME: sphinx: add update_web_docs_git.py script
@ 2022-11-08 14:35 Martin Liska
0 siblings, 0 replies; 8+ messages in thread
From: Martin Liska @ 2022-11-08 14:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9a2c883138863f8e103947b7b15ba416d7dd5688
commit 9a2c883138863f8e103947b7b15ba416d7dd5688
Author: Martin Liska <mliska@suse.cz>
Date: Mon Nov 7 22:07:47 2022 +0100
FIXME: sphinx: add update_web_docs_git.py script
maintainer-scripts/ChangeLog:
* update_web_docs_git.py: New file.
Diff:
---
maintainer-scripts/update_web_docs_git.py | 81 +++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/maintainer-scripts/update_web_docs_git.py b/maintainer-scripts/update_web_docs_git.py
new file mode 100755
index 00000000000..a02d0d1e6b0
--- /dev/null
+++ b/maintainer-scripts/update_web_docs_git.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+
+# Generate documentation from Sphinx files.
+
+import argparse
+import os
+import shutil
+import subprocess
+import tempfile
+from pathlib import Path
+
+GITROOT = '/git/gcc.git'
+BUGURL = 'https://gcc.gnu.org/bugs/'
+
+parser = argparse.ArgumentParser(description='Update web documentation.')
+parser.add_argument('output_folder', help='Output folder')
+parser.add_argument('--gitrepo', help=f'Git repository (default: {GITROOT})',
+ default=GITROOT)
+parser.add_argument('--sphinx-build', help='Path to sphinx-build binary')
+args = parser.parse_args()
+
+
+def find_configs():
+ for root, _, files in os.walk('.'):
+ for f in files:
+ full = os.path.join(root, f)
+ if f == 'conf.py':
+ # find name of the documentation
+ lines = open(full).read().splitlines()
+ docname = None
+ for line in lines:
+ if line.startswith('name = '):
+ docname = line.split()[-1].strip("'")
+ break
+ assert docname
+ yield (Path(root).resolve(), docname)
+
+
+with tempfile.TemporaryDirectory() as folder:
+ print(f'Using {folder} as temporary directory')
+ os.chdir(folder)
+ subprocess.check_output(f'git clone {args.gitrepo} --depth=1', shell=True)
+ # TODO: remove
+ os.chdir('gcc')
+ cmd = 'git fetch origin refs/users/marxin/heads/sphinx-final --depth=1'
+ subprocess.check_output(cmd, shell=True)
+ subprocess.check_output('git checkout FETCH_HEAD', shell=True)
+ configs = list(find_configs())
+
+ # Prepare folders
+ output = Path(args.output_folder)
+ if not output.exists():
+ output.mkdir()
+
+ temp = Path('tmp').resolve()
+ temp.mkdir()
+
+ # Prepare default env. variables
+ childenv = os.environ.copy()
+ childenv['BUGURL'] = BUGURL
+
+ # Build and copy the documentation
+ for config_folder, docname in sorted(configs):
+ print('=== BUILDING:', config_folder, docname, '===')
+
+ # Build HTML
+ cmd = f'make -C doc html SOURCEDIR={config_folder} BUILDDIR={temp}/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ os.unlink(f'{temp}/{docname}/html/.buildinfo')
+ shutil.copytree(f'{temp}/{docname}/html', f'{output}/{docname}',
+ dirs_exist_ok=True)
+
+ # Build PDF
+ cmd = f'make -C doc latexpdf SOURCEDIR={config_folder} BUILDDIR={temp}/pdf/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ shutil.copyfile(f'{temp}/pdf/{docname}/latex/{docname}.pdf',
+ f'{output}/{docname}.pdf')
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gcc(refs/users/marxin/heads/sphinx-final)] FIXME: sphinx: add update_web_docs_git.py script
@ 2022-11-08 12:07 Martin Liska
0 siblings, 0 replies; 8+ messages in thread
From: Martin Liska @ 2022-11-08 12:07 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:8eba0b1254c9597a8238cf80336ee7445d22c25f
commit 8eba0b1254c9597a8238cf80336ee7445d22c25f
Author: Martin Liska <mliska@suse.cz>
Date: Mon Nov 7 22:07:47 2022 +0100
FIXME: sphinx: add update_web_docs_git.py script
maintainer-scripts/ChangeLog:
* update_web_docs_git.py: New file.
Diff:
---
maintainer-scripts/update_web_docs_git.py | 81 +++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/maintainer-scripts/update_web_docs_git.py b/maintainer-scripts/update_web_docs_git.py
new file mode 100755
index 00000000000..a02d0d1e6b0
--- /dev/null
+++ b/maintainer-scripts/update_web_docs_git.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+
+# Generate documentation from Sphinx files.
+
+import argparse
+import os
+import shutil
+import subprocess
+import tempfile
+from pathlib import Path
+
+GITROOT = '/git/gcc.git'
+BUGURL = 'https://gcc.gnu.org/bugs/'
+
+parser = argparse.ArgumentParser(description='Update web documentation.')
+parser.add_argument('output_folder', help='Output folder')
+parser.add_argument('--gitrepo', help=f'Git repository (default: {GITROOT})',
+ default=GITROOT)
+parser.add_argument('--sphinx-build', help='Path to sphinx-build binary')
+args = parser.parse_args()
+
+
+def find_configs():
+ for root, _, files in os.walk('.'):
+ for f in files:
+ full = os.path.join(root, f)
+ if f == 'conf.py':
+ # find name of the documentation
+ lines = open(full).read().splitlines()
+ docname = None
+ for line in lines:
+ if line.startswith('name = '):
+ docname = line.split()[-1].strip("'")
+ break
+ assert docname
+ yield (Path(root).resolve(), docname)
+
+
+with tempfile.TemporaryDirectory() as folder:
+ print(f'Using {folder} as temporary directory')
+ os.chdir(folder)
+ subprocess.check_output(f'git clone {args.gitrepo} --depth=1', shell=True)
+ # TODO: remove
+ os.chdir('gcc')
+ cmd = 'git fetch origin refs/users/marxin/heads/sphinx-final --depth=1'
+ subprocess.check_output(cmd, shell=True)
+ subprocess.check_output('git checkout FETCH_HEAD', shell=True)
+ configs = list(find_configs())
+
+ # Prepare folders
+ output = Path(args.output_folder)
+ if not output.exists():
+ output.mkdir()
+
+ temp = Path('tmp').resolve()
+ temp.mkdir()
+
+ # Prepare default env. variables
+ childenv = os.environ.copy()
+ childenv['BUGURL'] = BUGURL
+
+ # Build and copy the documentation
+ for config_folder, docname in sorted(configs):
+ print('=== BUILDING:', config_folder, docname, '===')
+
+ # Build HTML
+ cmd = f'make -C doc html SOURCEDIR={config_folder} BUILDDIR={temp}/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ os.unlink(f'{temp}/{docname}/html/.buildinfo')
+ shutil.copytree(f'{temp}/{docname}/html', f'{output}/{docname}',
+ dirs_exist_ok=True)
+
+ # Build PDF
+ cmd = f'make -C doc latexpdf SOURCEDIR={config_folder} BUILDDIR={temp}/pdf/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ shutil.copyfile(f'{temp}/pdf/{docname}/latex/{docname}.pdf',
+ f'{output}/{docname}.pdf')
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gcc(refs/users/marxin/heads/sphinx-final)] FIXME: sphinx: add update_web_docs_git.py script
@ 2022-11-08 11:43 Martin Liska
0 siblings, 0 replies; 8+ messages in thread
From: Martin Liska @ 2022-11-08 11:43 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:36d48c3ba08f5a6d21ac53b8bd6aee7816c5787a
commit 36d48c3ba08f5a6d21ac53b8bd6aee7816c5787a
Author: Martin Liska <mliska@suse.cz>
Date: Mon Nov 7 22:07:47 2022 +0100
FIXME: sphinx: add update_web_docs_git.py script
maintainer-scripts/ChangeLog:
* update_web_docs_git.py: New file.
Diff:
---
maintainer-scripts/update_web_docs_git.py | 81 +++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/maintainer-scripts/update_web_docs_git.py b/maintainer-scripts/update_web_docs_git.py
new file mode 100755
index 00000000000..a02d0d1e6b0
--- /dev/null
+++ b/maintainer-scripts/update_web_docs_git.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+
+# Generate documentation from Sphinx files.
+
+import argparse
+import os
+import shutil
+import subprocess
+import tempfile
+from pathlib import Path
+
+GITROOT = '/git/gcc.git'
+BUGURL = 'https://gcc.gnu.org/bugs/'
+
+parser = argparse.ArgumentParser(description='Update web documentation.')
+parser.add_argument('output_folder', help='Output folder')
+parser.add_argument('--gitrepo', help=f'Git repository (default: {GITROOT})',
+ default=GITROOT)
+parser.add_argument('--sphinx-build', help='Path to sphinx-build binary')
+args = parser.parse_args()
+
+
+def find_configs():
+ for root, _, files in os.walk('.'):
+ for f in files:
+ full = os.path.join(root, f)
+ if f == 'conf.py':
+ # find name of the documentation
+ lines = open(full).read().splitlines()
+ docname = None
+ for line in lines:
+ if line.startswith('name = '):
+ docname = line.split()[-1].strip("'")
+ break
+ assert docname
+ yield (Path(root).resolve(), docname)
+
+
+with tempfile.TemporaryDirectory() as folder:
+ print(f'Using {folder} as temporary directory')
+ os.chdir(folder)
+ subprocess.check_output(f'git clone {args.gitrepo} --depth=1', shell=True)
+ # TODO: remove
+ os.chdir('gcc')
+ cmd = 'git fetch origin refs/users/marxin/heads/sphinx-final --depth=1'
+ subprocess.check_output(cmd, shell=True)
+ subprocess.check_output('git checkout FETCH_HEAD', shell=True)
+ configs = list(find_configs())
+
+ # Prepare folders
+ output = Path(args.output_folder)
+ if not output.exists():
+ output.mkdir()
+
+ temp = Path('tmp').resolve()
+ temp.mkdir()
+
+ # Prepare default env. variables
+ childenv = os.environ.copy()
+ childenv['BUGURL'] = BUGURL
+
+ # Build and copy the documentation
+ for config_folder, docname in sorted(configs):
+ print('=== BUILDING:', config_folder, docname, '===')
+
+ # Build HTML
+ cmd = f'make -C doc html SOURCEDIR={config_folder} BUILDDIR={temp}/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ os.unlink(f'{temp}/{docname}/html/.buildinfo')
+ shutil.copytree(f'{temp}/{docname}/html', f'{output}/{docname}',
+ dirs_exist_ok=True)
+
+ # Build PDF
+ cmd = f'make -C doc latexpdf SOURCEDIR={config_folder} BUILDDIR={temp}/pdf/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ shutil.copyfile(f'{temp}/pdf/{docname}/latex/{docname}.pdf',
+ f'{output}/{docname}.pdf')
^ permalink raw reply [flat|nested] 8+ messages in thread
* [gcc(refs/users/marxin/heads/sphinx-final)] FIXME: sphinx: add update_web_docs_git.py script
@ 2022-11-08 11:39 Martin Liska
0 siblings, 0 replies; 8+ messages in thread
From: Martin Liska @ 2022-11-08 11:39 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:f08aaf74a004cc57979c2b964a875b5df2c658a8
commit f08aaf74a004cc57979c2b964a875b5df2c658a8
Author: Martin Liska <mliska@suse.cz>
Date: Mon Nov 7 22:07:47 2022 +0100
FIXME: sphinx: add update_web_docs_git.py script
maintainer-scripts/ChangeLog:
* update_web_docs_git.py: New file.
Diff:
---
maintainer-scripts/update_web_docs_git.py | 81 +++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
diff --git a/maintainer-scripts/update_web_docs_git.py b/maintainer-scripts/update_web_docs_git.py
new file mode 100755
index 00000000000..a02d0d1e6b0
--- /dev/null
+++ b/maintainer-scripts/update_web_docs_git.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+
+# Generate documentation from Sphinx files.
+
+import argparse
+import os
+import shutil
+import subprocess
+import tempfile
+from pathlib import Path
+
+GITROOT = '/git/gcc.git'
+BUGURL = 'https://gcc.gnu.org/bugs/'
+
+parser = argparse.ArgumentParser(description='Update web documentation.')
+parser.add_argument('output_folder', help='Output folder')
+parser.add_argument('--gitrepo', help=f'Git repository (default: {GITROOT})',
+ default=GITROOT)
+parser.add_argument('--sphinx-build', help='Path to sphinx-build binary')
+args = parser.parse_args()
+
+
+def find_configs():
+ for root, _, files in os.walk('.'):
+ for f in files:
+ full = os.path.join(root, f)
+ if f == 'conf.py':
+ # find name of the documentation
+ lines = open(full).read().splitlines()
+ docname = None
+ for line in lines:
+ if line.startswith('name = '):
+ docname = line.split()[-1].strip("'")
+ break
+ assert docname
+ yield (Path(root).resolve(), docname)
+
+
+with tempfile.TemporaryDirectory() as folder:
+ print(f'Using {folder} as temporary directory')
+ os.chdir(folder)
+ subprocess.check_output(f'git clone {args.gitrepo} --depth=1', shell=True)
+ # TODO: remove
+ os.chdir('gcc')
+ cmd = 'git fetch origin refs/users/marxin/heads/sphinx-final --depth=1'
+ subprocess.check_output(cmd, shell=True)
+ subprocess.check_output('git checkout FETCH_HEAD', shell=True)
+ configs = list(find_configs())
+
+ # Prepare folders
+ output = Path(args.output_folder)
+ if not output.exists():
+ output.mkdir()
+
+ temp = Path('tmp').resolve()
+ temp.mkdir()
+
+ # Prepare default env. variables
+ childenv = os.environ.copy()
+ childenv['BUGURL'] = BUGURL
+
+ # Build and copy the documentation
+ for config_folder, docname in sorted(configs):
+ print('=== BUILDING:', config_folder, docname, '===')
+
+ # Build HTML
+ cmd = f'make -C doc html SOURCEDIR={config_folder} BUILDDIR={temp}/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ os.unlink(f'{temp}/{docname}/html/.buildinfo')
+ shutil.copytree(f'{temp}/{docname}/html', f'{output}/{docname}',
+ dirs_exist_ok=True)
+
+ # Build PDF
+ cmd = f'make -C doc latexpdf SOURCEDIR={config_folder} BUILDDIR={temp}/pdf/{docname}'
+ if args.sphinx_build:
+ cmd += f' SPHINXBUILD={args.sphinx_build}'
+ subprocess.check_output(cmd, shell=True, env=childenv)
+ shutil.copyfile(f'{temp}/pdf/{docname}/latex/{docname}.pdf',
+ f'{output}/{docname}.pdf')
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-11-08 14:54 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 11:24 [gcc(refs/users/marxin/heads/sphinx-final)] FIXME: sphinx: add update_web_docs_git.py script Martin Liska
2022-11-08 11:39 Martin Liska
2022-11-08 11:43 Martin Liska
2022-11-08 12:07 Martin Liska
2022-11-08 14:35 Martin Liska
2022-11-08 14:36 Martin Liska
2022-11-08 14:43 Martin Liska
2022-11-08 14:54 Martin Liska
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).