mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-25 09:40:23 -07:00
Docs: Make docsite rebuilds smarter/faster (#45062)
* Make the following scripts idempotent so that we only have to rebuild changed docs, not all docs: * plugin_formatter * generate_man * dump_keywords.py * dump_config.py * testing_formatter.sh
This commit is contained in:
parent
6e68d77f6d
commit
310b0a2521
8 changed files with 61 additions and 32 deletions
38
lib/ansible/utils/_build_helpers.py
Normal file
38
lib/ansible/utils/_build_helpers.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Copyright: (c) 2018, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
"""
|
||||
This file contains common code for building ansible. If you want to use code from here at runtime,
|
||||
it needs to be moved out of this file and the implementation looked over to figure out whether API
|
||||
should be changed before being made public.
|
||||
"""
|
||||
|
||||
import os.path
|
||||
|
||||
|
||||
def update_file_if_different(filename, b_data):
|
||||
'''
|
||||
Replace file content only if content is different.
|
||||
|
||||
This preserves timestamps in case the file content has not changed. It performs multiple
|
||||
operations on the file so it is not atomic and may be slower than simply writing to the file.
|
||||
|
||||
:arg filename: The filename to write to
|
||||
:b_data: Byte string containing the data to write to the file
|
||||
'''
|
||||
try:
|
||||
with open(filename, 'rb') as f:
|
||||
b_data_old = f.read()
|
||||
except IOError as e:
|
||||
if e.errno != 2:
|
||||
raise
|
||||
# File did not exist, set b_data_old to a sentinel value so that
|
||||
# b_data gets written to the filename
|
||||
b_data_old = None
|
||||
|
||||
if b_data_old != b_data:
|
||||
with open(filename, 'wb') as f:
|
||||
f.write(b_data)
|
|
@ -1,22 +1,6 @@
|
|||
# (c) 2012, Jan-Piet Mens <jpmens () gmail.com>
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Copyright: (c) 2012, Jan-Piet Mens <jpmens () gmail.com>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue