diff --git a/.gitignore b/.gitignore
index 33b7a46..9a5fc2e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,8 +2,10 @@
*.o
*.so
-# unified repo tracking
+# sparse-export stuff
.gitu
+.sparse-export
+tangent/tooling/sparse-exports
# qt creator
*.qtc.*
diff --git a/.readthedocs.yml b/.readthedocs.yml
new file mode 100644
index 0000000..3f3c4db
--- /dev/null
+++ b/.readthedocs.yml
@@ -0,0 +1,20 @@
+# .readthedocs.yml
+# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
+
+version: 2
+sphinx:
+ configuration: conf.py
+
+build:
+ image: latest
+
+formats: all
+python:
+ version: 3.7
+ install:
+ - requirements: requirements.txt
+ - method: pip
+ path: .
+ extra_requirements:
+ - YAML
+ - html-gen
diff --git a/.sparse-export b/.sparse-export
new file mode 100644
index 0000000..1890643
--- /dev/null
+++ b/.sparse-export
@@ -0,0 +1 @@
+tangent/tooling/sparse-exports/cmake_format
diff --git a/.travis.yml b/.travis.yml
index fd360fa..b0da2b6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,13 +1,42 @@
dist: xenial
language: python
python:
- - "2.7"
- - "3.5"
- - "3.6"
+- '2.7'
+- '3.5'
+- '3.6'
+
+before_install:
+- sudo apt-get update
+- sudo apt-get -y install pandoc
install:
- - pip install -r requirements.txt
+- pip install -r requirements.txt
script:
- - make better-test
- - make lint
+- make better-test
+- make lint
+
+env:
+ global:
+ # GITHUB_ACCESS_TOKEN=
+ secure: "e62y3i4FG7KsJ/I8aVKoPk5CG0L7/TW1K4M+BLt5zULsKGyRw6b53I97p5Tc1zcAHqcocFeYL/eC3AucG3VNvyv6LIZuv5Y0upF/MG++tvkfV9Iyok76mP70DXR/ikAJDMgZSdEL/6uTTJ4XfBuH/VvCMMBvj+5ORSL65KIfqXcexj2JWaNtEEfwiVSkDvQZYYbHLRjQdAXzzI7g1xh+8mCmuFAvtn6U1cIZpdQv5u1DNIry8PoQ2asHr+vaCN9iVXvkWcUjoXpJTp96Hd8eO40ts3v3Ja1yJ7GzH09zjbKJS63dcB0LfV5uLjybJCkQ03102ua0V+E5OzPn5VYeIRSRWmdo35e9xZjqqbtNdHqNayOOpew/ik+wf2Nmzva5MCRf154pFfWjBDL4zh0WGBW8FyJ/9NxdYDJsOIznHBPBHCXnQOlrpdInIptuoLnT52V7MOq9XIiuqLlAH8Tr0GzNSJIJfwwhwJuGxgYi2DPDH8PRmkbHbvY/mN2WBxNFfHBSfCQGZJt6kHtEE+xIi0QQXME0h36V/8sOsmQDzArNFl2Um5GCXodtIjZI6Ga3nQhHDRRiQKJz0V/9OsJF4GteGw94xt/l6PkCT0o4D1cmPIELrBTzaEMnXYKRQEOPnvViyV8eJF2RBnaqNk+FqI+hmGtXXUKAdXZWAzyS66I="
+
+jobs:
+ include:
+ - stage: deploy
+ name: deploy-tag
+ if: repo = cheshirekow/cmake_format
+ AND NOT tag IS present
+ AND branch =~ ^((master)|(staging))$
+ python: 3.6
+ script:
+ - make push-github-pseudorelease-tag
+ - name: deploy-artifacts
+ python: 3.6
+ if: repo = cheshirekow/cmake_format
+ AND tag IS present
+ AND (tag =~ ^pseudo-((master)|(staging))$
+ OR tag =~ ^v\d+\.\d+\.\d+)
+ script:
+ - make push-github-release
+ - make push-rtd-repo
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 58be4a4..7f8cbf5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,11 +3,13 @@ project(cheshirekow)
enable_testing()
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
+include(${CMAKE_SOURCE_DIR}/cmake/environment.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/codestyle.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/ctest_helpers.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/doctools.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/pkgconfig.cmake)
+detect_buildenv()
find_package(Threads REQUIRED)
pkg_find(
PKG eigen3
@@ -40,15 +42,18 @@ set(CXX_STANDARD
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=${CXX_STANDARD}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
+add_custom_target(doc)
add_custom_target(format)
+add_custom_target(gen)
add_custom_target(lint)
-
-add_custom_target(doc)
+add_custom_target(test-deps)
set(ENV{PYTHONPATH} ${CMAKE_SOURCE_DIR})
set(CTEST_ENVIRONMENT "PYTHONPATH=${CMAKE_SOURCE_DIR}")
-set_property(GLOBAL PROPERTY gloal_doc_files "")
+# Will be populated by subdirectory listfiles with the dependencies of the
+# master sphinx build
+set_property(GLOBAL PROPERTY global_doc_files "")
# NOTE(josh): search through the list of child directories and add any that
# actually contain a listfile. While globs are evil, this is necessary for
@@ -87,8 +92,37 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/doxy.config.in)
add_dependencies(doc doxygen)
endif()
+# Validate sparse or update sparse export
+add_custom_target(
+ update-export
+ COMMAND python -Bm tangent.tooling.export_sparse_subrepo update
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Updataing sparse export")
+
+add_test(
+ NAME verify-export
+ COMMAND python -Bm tangent.tooling.export_sparse_subrepo update
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
add_custom_target(
better-test
+ DEPENDS test-deps
COMMAND ctest --force-new-ctest-process --output-on-failure
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Execute ctest")
+
+add_custom_target(
+ buildbot-test
+ DEPENDS test-deps
+ COMMAND ctest
+ # cmake-format: off
+ --label-exclude CI_DISABLED
+ --force-new-ctest-process
+ --output-on-failure
+ --output-log ${CMAKE_BINARY_DIR}/ctestlog.txt
+ # cmake-format: on
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+)
+
+add_custom_target(pre-push)
+add_dependencies(pre-push better-test doc format gen lint)
diff --git a/Makefile b/Makefile
index 696be0e..a16ffb4 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,6 @@ test: all
@echo "Bootstraping build system"
mkdir -p .build
touch .build/CMakeCache.txt
- cd .build && env cmake -DIS_TRAVIS_CI=True ../
+ cd .build && env cmake ../
PHONY: all doc test
diff --git a/cmake/codestyle.cmake b/cmake/codestyle.cmake
index d2449e0..d014c51 100644
--- a/cmake/codestyle.cmake
+++ b/cmake/codestyle.cmake
@@ -58,13 +58,13 @@ function(format_and_lint module)
string(TOLOWER ${arg} typename_)
set(active_list_ ${typename_}_files_)
else()
- if(arg MATCHES ".*\.cmake" OR arg MATCHES ".*CMakeLists.txt")
+ if(arg MATCHES ".*\.cmake$" OR arg MATCHES ".*CMakeLists.txt")
list(APPEND cmake_files_ ${arg})
- elseif(arg MATCHES ".*\.py")
+ elseif(arg MATCHES ".*\.py$")
list(APPEND py_files_ ${arg})
- elseif(arg MATCHES ".*\.(c|cc|h)")
+ elseif(arg MATCHES ".*\.(c|cc|h|hpp)$")
list(APPEND cc_files_ ${arg})
- elseif(arg MATCHES ".*\.js(\.tpl)?")
+ elseif(arg MATCHES ".*\.js(\.tpl)?$")
list(APPEND js_files_ ${arg})
else()
list(APPEND unknown_files_ ${arg})
diff --git a/cmake/environment.cmake b/cmake/environment.cmake
new file mode 100644
index 0000000..eb017bf
--- /dev/null
+++ b/cmake/environment.cmake
@@ -0,0 +1,17 @@
+function(detect_buildenv)
+ if(DEFINED ENV{CI}
+ AND DEFINED ENV{TRAVIS}
+ AND "$ENV{CI}" STREQUAL "true"
+ AND "$ENV{TRAVIS}" STREQUAL "true")
+ set(IS_TRAVIS_CI TRUE PARENT_SCOPE)
+ else()
+ set(IS_TRAVIS_CI FALSE PARENT_SCOPE)
+ endif()
+
+ if(DEFINED ENV{TRAVIS_PULL_REQUEST}
+ AND "$ENV{TRAVIS_PULL_REQUEST}" STREQUAL "true")
+ set(IS_PULL_REQUEST TRUE PARENT_SCOPE)
+ else()
+ set(IS_PULL_REQUEST FALSE PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/cmake_format/BUILD b/cmake_format/BUILD
index e60453e..e53d03e 100644
--- a/cmake_format/BUILD
+++ b/cmake_format/BUILD
@@ -28,6 +28,8 @@ py_library(
"parse/simple_nodes.py",
"parse/statement_node.py",
"parse/util.py",
+ "parse/properties.py",
+ "parse/variables.py",
"parse_funs/__init__.py",
"parse_funs/add_executable.py",
"parse_funs/add_library.py",
diff --git a/cmake_format/CMakeLists.txt b/cmake_format/CMakeLists.txt
index 891490c..8c065ad 100644
--- a/cmake_format/CMakeLists.txt
+++ b/cmake_format/CMakeLists.txt
@@ -23,10 +23,10 @@ format_and_lint(
contrib/validate_pullrequest.py
ctest_to.py
doc/__init__.py
+ doc/bits/dump-example.cmake
doc/CMakeLists.txt
doc/conf.py
- doc/docsources_test.py
- doc/gendoc_sources.py
+ doc/gendoc.py
formatter.py
genparsers.py
invocation_tests.py
@@ -41,9 +41,11 @@ format_and_lint(
parse/body_nodes.py
parse/common.py
parse/printer.py
+ parse/properties.py
parse/simple_nodes.py
parse/statement_node.py
parse/util.py
+ parse/variables.py
parse_funs/__init__.py
parse_funs/add_executable.py
parse_funs/add_library.py
@@ -72,8 +74,12 @@ format_and_lint(
tests.py
tools/__init__.py
tools/bump_version.py
+ tools/create_pseudorelease_tag.py
+ tools/gen_rtd_requirements.py
tools/generate_missing_parsers.py
+ tools/get_release_notes.py
tools/parse_cmake_help.py
+ tools/push_github_release.py
tools/usage_lexer.py
tools/usage_parser.py)
@@ -96,15 +102,114 @@ if(NOT IS_TRAVIS_CI)
endforeach()
endif()
-add_subdirectory(command_tests)
-add_subdirectory(contrib)
-add_subdirectory(doc)
-add_subdirectory(test)
-
add_test(
NAME cmake_format-check-lint-manifest
COMMAND
python -Bm cmake.validate_lint_manifest #
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} #
- --exclude "command_tests/" "test/.*" ".*\\.jinja.py$"
+ --exclude "command_tests/" "doc/stage" "test/.*" ".*\\.jinja.py$"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+set(_genfiles)
+
+add_custom_command(
+ OUTPUT cmake_format/parse/variables.py
+ COMMAND python -Bm cmake_format.tools.parse_cmake_help --outfile
+ cmake_format/parse/variables.py variables
+ DEPENDS tools/parse_cmake_help.py tools/variables.jinja.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Generating variables.py")
+list(APPEND _genfiles cmake_format/parse/variables.py)
+
+
+add_custom_command(
+ OUTPUT cmake_format/parse/properties.py
+ COMMAND python -Bm cmake_format.tools.parse_cmake_help --outfile
+ cmake_format/parse/properties.py properties
+ DEPENDS tools/parse_cmake_help.py tools/properties.jinja.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Generating properties.py")
+list(APPEND _genfiles cmake_format/parse/properties.py)
+
+add_custom_target(
+ gen-cmake_format
+ DEPENDS ${_genfiles})
+add_dependencies(gen gen-cmake_format)
+
+# NOTE(josh): this is just here to induce a dependency on the configure step.
+# If we change the version number in __init__.py we need to re-run cmake so we
+# can get out the version number and create rules for the distribution files.
+configure_file(__init__.py init.stamp COPYONLY)
+
+execute_process(
+ COMMAND python -Bm cmake_format --version
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE _resultcode
+ OUTPUT_VARIABLE _version
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(NOT _resultcode EQUAL 0)
+ message(
+ FATAL_ERROR "Failed to get cmake-format version number from __init__.py")
+endif()
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/.egg
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/.egg
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+set(_distdir ${CMAKE_CURRENT_BINARY_DIR}/dist)
+add_custom_command(
+ OUTPUT
+ ${_distdir}/cmake_format-${_version}.tar.gz
+ ${_distdir}/cmake_format-${_version}-py3-none-any.whl
+ COMMAND
+ # cmake-format: off
+ python cmake_format/pypi/setup.py
+ build --build-base ${CMAKE_CURRENT_BINARY_DIR}
+ egg_info --egg-base ${CMAKE_CURRENT_BINARY_DIR}/.egg
+ bdist_wheel
+ --bdist-dir ${CMAKE_CURRENT_BINARY_DIR}/bdist
+ --dist-dir ${_distdir}
+ sdist --dist-dir ${_distdir}
+ # cmake-format: on
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/.egg
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/release_notes-${_version}.rst
+ COMMAND python -Bm cmake_format.tools.get_release_notes
+ cmake_format/doc/release_notes.rst \$\${TRAVIS_TAG}
+ -o ${CMAKE_CURRENT_BINARY_DIR}/release_notes-${_version}.rst
+ DEPENDS doc/release_notes.rst
+ tools/get_release_notes.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/release_notes-${_version}.md
+ COMMAND pandoc -s
+ -o ${CMAKE_CURRENT_BINARY_DIR}/release_notes-${_version}.md
+ ${CMAKE_CURRENT_BINARY_DIR}/release_notes-${_version}.rst
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/release_notes-${_version}.rst
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+add_custom_target(
+ push-github-release
+ COMMAND
+ # cmake-format: off
+ python -Bm cmake_format.tools.push_github_release
+ --message ${CMAKE_CURRENT_BINARY_DIR}/release_notes-${_version}.md
+ \$\${TRAVIS_TAG}
+ ${_distdir}/cmake_format-${_version}.tar.gz
+ ${_distdir}/cmake_format-${_version}-py3-none-any.whl
+ # cmake-format: on
+ DEPENDS
+ ${CMAKE_CURRENT_BINARY_DIR}/release_notes-${_version}.md
+ ${_distdir}/cmake_format-${_version}.tar.gz
+ ${_distdir}/cmake_format-${_version}-py3-none-any.whl
+ COMMENT "Uploading release artifacts"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+add_subdirectory(command_tests)
+add_subdirectory(contrib)
+add_subdirectory(doc)
+add_subdirectory(test)
diff --git a/cmake_format/__init__.py b/cmake_format/__init__.py
index 62aea45..652529b 100644
--- a/cmake_format/__init__.py
+++ b/cmake_format/__init__.py
@@ -3,4 +3,4 @@
"""
from __future__ import unicode_literals
-VERSION = '0.6.7'
+VERSION = '0.6.8.dev0'
diff --git a/cmake_format/__main__.py b/cmake_format/__main__.py
index f30fb09..afa5e4b 100644
--- a/cmake_format/__main__.py
+++ b/cmake_format/__main__.py
@@ -116,7 +116,7 @@ def process_file(config, infile_content, dump=None):
for token in tokens:
outfile.write("{}\n".format(token))
return outfile.getvalue(), True
- config.first_token = lexer.get_first_non_whitespace_token(tokens)
+ first_token = lexer.get_first_non_whitespace_token(tokens)
parse_db = parse_funs.get_parse_db()
parse_db.update(parse_funs.get_legacy_parse(config.parse.fn_spec).kwargs)
ctx = parse.ParseContext(parse_db, config=config)
@@ -128,7 +128,7 @@ def process_file(config, infile_content, dump=None):
dump_markup([parse_tree], config, outfile)
return outfile.getvalue(), True
- box_tree = formatter.layout_tree(parse_tree, config)
+ box_tree = formatter.layout_tree(parse_tree, config, first_token=first_token)
if dump == "layout":
formatter.dump_tree([box_tree], outfile)
return outfile.getvalue(), True
@@ -229,14 +229,32 @@ def get_one_config_dict(configfile_path):
"""
if configfile_path.endswith('.json'):
with io.open(configfile_path, 'r', encoding='utf-8') as config_file:
- return json.load(config_file)
+ try:
+ return json.load(config_file)
+ except ValueError as ex:
+ message = (
+ "Failed to parse json config file {}: {}"
+ .format(configfile_path, ex))
+ raise common.UserError(message)
if configfile_path.endswith('.yaml'):
with io.open(configfile_path, 'r', encoding='utf-8') as config_file:
- return load_yaml(config_file)
+ try:
+ return load_yaml(config_file)
+ except ValueError as ex:
+ message = (
+ "Failed to parse yaml config file {}: {}"
+ .format(configfile_path, ex))
+ raise common.UserError(message)
if configfile_path.endswith('.py'):
- return exec_pyconfig(configfile_path)
+ try:
+ return exec_pyconfig(configfile_path)
+ except Exception as ex:
+ message = (
+ "Failed to parse python config file {}: {}"
+ .format(configfile_path, ex))
+ raise common.UserError(message)
return try_get_configdict(configfile_path)
@@ -248,6 +266,7 @@ def get_configdict(configfile_paths):
configfile_path = include_queue.pop(0)
configfile_path = os.path.expanduser(configfile_path)
increment_dict = get_one_config_dict(configfile_path)
+
for include_path in increment_dict.pop("include", []):
if not os.path.isabs(include_path):
include_path = os.path.join(
diff --git a/cmake_format/annotate.py b/cmake_format/annotate.py
index e7ae7ec..a752670 100644
--- a/cmake_format/annotate.py
+++ b/cmake_format/annotate.py
@@ -26,6 +26,21 @@
from cmake_format import render
+EMBED_TPL = """
+
+{{html_content}}
+
+
+
+"""
+
+
def annotate_file(config, infile, outfile, outfmt=None):
"""
Parse the input cmake file, re-format it, and print to the output file.
@@ -37,7 +52,6 @@ def annotate_file(config, infile, outfile, outfmt=None):
config = config.clone()
config.format.set_line_ending(detected)
tokens = lexer.tokenize(infile_content)
- config.first_token = lexer.get_first_non_whitespace_token(tokens)
parse_db = parse_funs.get_parse_db()
parse_db.update(parse_funs.get_legacy_parse(config.parse.fn_spec).kwargs)
ctx = parse.ParseContext(parse_db)
@@ -51,6 +65,18 @@ def annotate_file(config, infile, outfile, outfmt=None):
html_content = render.get_html(parse_tree, fullpage=False)
outfile.write(html_content)
return
+ if outfmt == "iframe":
+ html_content = render.get_html(parse_tree, fullpage=True)
+ wrap_lines = EMBED_TPL.split("\n")
+ for line in wrap_lines[:2]:
+ outfile.write(line)
+ outfile.write("\n")
+ outfile.write(html_content)
+ for line in wrap_lines[3:]:
+ outfile.write(line)
+ outfile.write("\n")
+ return
+
raise ValueError("Invalid output format: {}".format(outfmt))
@@ -70,7 +96,7 @@ def setup_argparser(arg_parser):
arg_parser.add_argument('-v', '--version', action='version',
version=cmake_format.VERSION)
arg_parser.add_argument(
- "-f", "--format", choices=["page", "stub"], default="stub",
+ "-f", "--format", choices=["page", "stub", "iframe"], default="stub",
help="whether to output a standalone `page` complete with "
"tags, or just the annotated content")
diff --git a/cmake_format/command_tests/CMakeLists.txt b/cmake_format/command_tests/CMakeLists.txt
index d5fe454..38aa2ff 100644
--- a/cmake_format/command_tests/CMakeLists.txt
+++ b/cmake_format/command_tests/CMakeLists.txt
@@ -1,19 +1,17 @@
set(MODPREFIX cmake_format.command_tests)
-set(
- _testnames
- TestAddCustomCommand
- TestAddExecutableCommand
- TestAddLibraryCommand
- TestConditional
- TestExport
- TestFile
- TestForeach
- TestInstall
- TestMiscFormatting
- TestSetTargetProperties
- TestSet
-)
+set(_testnames
+ TestAddCustomCommand
+ TestAddExecutableCommand
+ TestAddLibraryCommand
+ TestConditional
+ TestExport
+ TestFile
+ TestForeach
+ TestInstall
+ TestMiscFormatting
+ TestSetTargetProperties
+ TestSet)
foreach(_testname ${_testnames})
add_test(
diff --git a/cmake_format/command_tests/__init__.py b/cmake_format/command_tests/__init__.py
index 1c70f90..b7ef772 100644
--- a/cmake_format/command_tests/__init__.py
+++ b/cmake_format/command_tests/__init__.py
@@ -481,6 +481,13 @@ class TestAddCustomCommand(TestBase):
kExpectNumSidecarTests = 4
+class TestComment(TestBase):
+ """
+ Test various examples involving comments
+ """
+ kExpectNumSidecarTests = 3
+
+
class TestConditional(TestBase):
"""
Test various examples of commands that take conditional statements
diff --git a/cmake_format/command_tests/__main__.py b/cmake_format/command_tests/__main__.py
index 01634be..f851f39 100644
--- a/cmake_format/command_tests/__main__.py
+++ b/cmake_format/command_tests/__main__.py
@@ -4,6 +4,7 @@
from cmake_format.command_tests import (
TestAddCustomCommand,
TestConditional,
+ TestComment,
TestCustomCommand,
TestExport,
TestExternalProject,
@@ -11,7 +12,7 @@
TestForeach,
TestInstall,
TestSetTargetProperties,
- TestSet,)
+ TestSet)
from cmake_format.command_tests.add_executable_tests \
import TestAddExecutableCommand
diff --git a/cmake_format/command_tests/comment_tests.cmake b/cmake_format/command_tests/comment_tests.cmake
new file mode 100644
index 0000000..c3d0aa5
--- /dev/null
+++ b/cmake_format/command_tests/comment_tests.cmake
@@ -0,0 +1,27 @@
+# test: format_off_code
+# No, I really want this to look ugly
+# cmake-format: off
+add_library(a b.cc
+ c.cc d.cc
+ e.cc)
+# cmake-format: on
+
+# test: format_off_nested
+add_custom_target(
+ push-github-release
+ COMMAND
+ # cmake-format: off
+ python -Bm cmake_format.tools.push_github_release
+ --message ${CMAKE_CURRENT_BINARY_DIR}/release_notes-${_version}.md
+ $ENV{TRAVIS_TAG}
+ ${_distdir}/cmake-format-${_version}.tar.gz
+ ${_distdir}/cmake-format-${_version}-py3-none-any.whl
+ # cmake-format: on
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/release_notes-${_version}.md
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+
+# test: multiline comment in statement
+add_custom_target(
+ my-target COMMAND foo bar baz # This comment is a trailing comment
+ # But this comment is a line comment
+)
diff --git a/cmake_format/command_tests/misc_tests.cmake b/cmake_format/command_tests/misc_tests.cmake
index f9623f0..e71ba72 100644
--- a/cmake_format/command_tests/misc_tests.cmake
+++ b/cmake_format/command_tests/misc_tests.cmake
@@ -67,14 +67,6 @@ foo(some_arg some_arg "
This string is on multiple lines
")
-# test: format_off_code
-# No, I really want this to look ugly
-# cmake-format: off
-add_library(a b.cc
- c.cc d.cc
- e.cc)
-# cmake-format: on
-
# test: multiline_statment_comment_idempotent
set(HELLO hello world!) # TODO(josh): fix this bad code with some change that
# takes mutiple lines to explain
diff --git a/cmake_format/command_tests/misc_tests.py b/cmake_format/command_tests/misc_tests.py
index 213b1d0..83c0912 100644
--- a/cmake_format/command_tests/misc_tests.py
+++ b/cmake_format/command_tests/misc_tests.py
@@ -15,7 +15,7 @@ class TestMiscFormatting(TestBase):
"""
Ensure that various inputs format the way we want them to
"""
- kExpectNumSidecarTests = 82
+ kExpectNumSidecarTests = 81
def test_config_hashruler_minlength(self):
diff --git a/cmake_format/configuration.py b/cmake_format/configuration.py
index b088a33..c6334d2 100644
--- a/cmake_format/configuration.py
+++ b/cmake_format/configuration.py
@@ -1,6 +1,7 @@
from __future__ import unicode_literals
import logging
+import re
from cmake_format import commands
from cmake_format import markup
@@ -183,8 +184,6 @@ class LinterConfig(ConfigObject):
'DEPENDS': '*'
}
}
-
-
}
@@ -197,39 +196,47 @@ class FormattingConfig(ConfigObject):
80,
"How wide to allow formatted cmake files"
)
+
tab_size = FieldDescriptor(
2,
"How many spaces to tab for indent"
)
+
max_subgroups_hwrap = FieldDescriptor(
2,
"If an argument group contains more than this many sub-groups "
"(parg or kwarg groups) then force it to a vertical layout. "
)
+
max_pargs_hwrap = FieldDescriptor(
6,
"If a positional argument group contains more than this many"
" arguments, then force it to a vertical layout. "
)
+
max_rows_cmdline = FieldDescriptor(
2,
"If a cmdline positional group consumes more than this many lines"
" without nesting, then invalidate the layout (and nest)"
)
+
separate_ctrl_name_with_space = FieldDescriptor(
False,
"If true, separate flow control names from their parentheses with a"
" space"
)
+
separate_fn_name_with_space = FieldDescriptor(
False,
"If true, separate function names from parentheses with a space"
)
+
dangle_parens = FieldDescriptor(
False,
"If a statement is wrapped to more than one line, than dangle the"
" closing parenthesis on its own line."
)
+
dangle_align = FieldDescriptor(
"prefix",
"If the trailing parenthesis must be 'dangled' on its on line, then"
@@ -238,51 +245,61 @@ class FormattingConfig(ConfigObject):
" level, `child`: align to the column of the arguments",
["prefix", "prefix-indent", "child", "off"],
)
+
min_prefix_chars = FieldDescriptor(
4,
"If the statement spelling length (including space and parenthesis)"
" is smaller than this amount, then force reject nested layouts."
)
+
max_prefix_chars = FieldDescriptor(
10,
"If the statement spelling length (including space and parenthesis)"
" is larger than the tab width by more than this amount, then"
" force reject un-nested layouts."
)
+
max_lines_hwrap = FieldDescriptor(
2,
"If a candidate layout is wrapped horizontally but it exceeds this"
" many lines, then reject the layout."
)
+
line_ending = FieldDescriptor(
"unix",
"What style line endings to use in the output.",
['windows', 'unix', 'auto']
)
+
command_case = FieldDescriptor(
"canonical",
"Format command names consistently as 'lower' or 'upper' case",
['lower', 'upper', 'canonical', 'unchanged']
)
+
keyword_case = FieldDescriptor(
"unchanged",
"Format keywords consistently as 'lower' or 'upper' case",
['lower', 'upper', 'unchanged']
)
+
always_wrap = FieldDescriptor(
[],
"A list of command names which should always be wrapped"
)
+
enable_sort = FieldDescriptor(
True,
"If true, the argument lists which are known to be sortable will be "
"sorted lexicographicall"
)
+
autosort = FieldDescriptor(
False,
"If true, the parsers may infer whether or not an argument list is"
" sortable (without annotation)."
)
+
require_valid_layout = FieldDescriptor(
False,
"By default, if cmake-format cannot successfully fit everything into"
@@ -322,6 +339,15 @@ def _update_derived(self):
}[self.line_ending]
+BUILTIN_VARTAGS = [
+ (".*_COMMAND", ["cmdline"])
+]
+
+BUILTIN_PROPTAGS = [
+ (".*_DIRECTORIES", ["file-list"])
+]
+
+
class ParseConfig(ConfigObject):
"""Options affecting listfile parsing"""
@@ -332,13 +358,25 @@ class ParseConfig(ConfigObject):
"Specify structure for custom cmake functions"
)
+ vartags = FieldDescriptor([], "Specify variable tags.")
+ proptags = FieldDescriptor([], "Specify property tags.")
+
def _update_derived(self):
if self.additional_commands is not None:
for command_name, spec in self.additional_commands.items():
self.fn_spec.add(command_name, **spec)
+ self.vartags_ = [
+ (re.compile(pattern, re.IGNORECASE), tags) for pattern, tags in
+ BUILTIN_VARTAGS + self.vartags]
+ self.proptags_ = [
+ (re.compile(pattern, re.IGNORECASE), tags) for pattern, tags in
+ BUILTIN_PROPTAGS + self.proptags]
+
def __init__(self, **kwargs): # pylint: disable=W0613
self.fn_spec = commands.get_fn_spec()
+ self.vartags_ = []
+ self.proptags_ = []
super(ParseConfig, self).__init__(**kwargs)
@@ -382,14 +420,6 @@ class Configuration(ConfigObject):
encode = SubtreeDescriptor(EncodingConfig)
misc = SubtreeDescriptor(MiscConfig)
- def __init__(self, **kwargs): # pylint: disable=W0613
- super(Configuration, self).__init__(**kwargs)
-
- # TODO(josh): this does not belong here! We need some global state for
- # formatting and the only thing we have accessible through the whole format
- # stack is this config object... so I'm abusing it by adding this field here
- self.first_token = None
-
def resolve_for_command(self, command_name, config_key, default_value=None):
"""
Check for a per-command value or override of the given configuration key
diff --git a/cmake_format/doc/.readthedocs.yml b/cmake_format/doc/.readthedocs.yml
new file mode 100644
index 0000000..192a878
--- /dev/null
+++ b/cmake_format/doc/.readthedocs.yml
@@ -0,0 +1,15 @@
+# .readthedocs.yml
+# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
+
+version: 2
+sphinx:
+ configuration: conf.py
+
+build:
+ image: latest
+
+formats: all
+python:
+ version: 3.7
+ install:
+ - requirements: rtd-requirements.txt
diff --git a/cmake_format/doc/BUILD b/cmake_format/doc/BUILD
index 4227881..ad72a6a 100644
--- a/cmake_format/doc/BUILD
+++ b/cmake_format/doc/BUILD
@@ -4,26 +4,7 @@ py_library(
name="doc_tests",
srcs=[
"__init__.py",
- "conf.py",
- "docsources_test.py",
- "gendoc_sources.py"],
+ "conf.py"],
data=[])
-# -- Python 2 --
-
-py_test(
- name="docsources_test",
- srcs=["docsources_test.py"],
- deps=["//cmake_format:cmake_format", ":doc_tests"],
- python_version="PY2",
- )
-
-# -- Python 3 --
-
-py_test(
- name="docsources_test_py3",
- srcs=["docsources_test.py"],
- main="docsources_test.py",
- deps=["//cmake_format:cmake_format", ":doc_tests"],
- python_version="PY3",
- )
+# TODO(josh): add genfile rules
diff --git a/cmake_format/doc/CMakeLists.txt b/cmake_format/doc/CMakeLists.txt
index 23e2bf0..fe6593e 100644
--- a/cmake_format/doc/CMakeLists.txt
+++ b/cmake_format/doc/CMakeLists.txt
@@ -1,75 +1,382 @@
-add_custom_target(
- scanrst-cmake_format_docs
+#
+# Generated source bits for sphinx documentation
+#
+set(_stage ${CMAKE_CURRENT_BINARY_DIR}/stage)
+set(_genbits)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${_stage}/bits
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/format-usage.txt)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/format-usage.txt
+ COMMAND python -Bm cmake_format --help > ${_stage}/bits/format-usage.txt
+ DEPENDS ${_stage}/bits #
+ ../__main__.py #
+ ../configuration.py #
+ ../config_util.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/format-usage.txt)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/annotate-usage.txt
+ COMMAND python -Bm cmake_format.annotate --help >
+ ${_stage}/bits/annotate-usage.txt
+ DEPENDS ${_stage}/bits #
+ ../__main__.py #
+ ../annotate.py #
+ ../configuration.py #
+ ../config_util.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/annotate-usage.txt)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/ctest-to-usage.txt
+ COMMAND python -Bm cmake_format.ctest_to --help >
+ ${_stage}/bits/ctest-to-usage.txt
+ DEPENDS ${_stage}/bits #
+ ../__main__.py #
+ ../ctest_to.py #
+ ../configuration.py #
+ ../config_util.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/ctest-to-usage.txt)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/lint-usage.txt
+ COMMAND python -Bm cmake_lint --help > ${_stage}/bits/lint-usage.txt
+ DEPENDS ${_stage}/bits #
+ ../../cmake_lint/__main__.py #
+ ../__main__.py #
+ ../ctest_to.py #
+ ../configuration.py #
+ ../config_util.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/lint-usage.txt)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/configbits.py
+ COMMAND python -Bm cmake_format --dump-config > ${_stage}/bits/configbits.py
+ DEPENDS ${_stage}/bits #
+ ../__main__.py #
+ ../configuration.py #
+ ../config_util.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/configbits.py)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/lint-in.cmake
+ COMMAND ${CMAKE_COMMAND} -E copy cmake_lint/test/expect_lint.cmake
+ ${_stage}/bits/lint-in.cmake
+ DEPENDS ${_stage}/bits #
+ ${CMAKE_SOURCE_DIR}/cmake_lint/test/expect_lint.cmake
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/lint-in.cmake)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/lint-out.cmake
+ COMMAND python -Bm cmake_lint cmake_lint/test/expect_lint.cmake >
+ ${_stage}/bits/lint-out.cmake || echo "OK"
+ DEPENDS ${_stage}/bits #
+ ../../cmake_lint/__main__.py #
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/lint-out.cmake)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/dump-example-src.cmake
+ COMMAND ${CMAKE_COMMAND} -E copy cmake_format/doc/bits/dump-example.cmake
+ ${_stage}/bits/dump-example-src.cmake
+ DEPENDS ${_stage}/bits #
+ bits/dump-example.cmake
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/dump-example-src.cmake)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/dump-example-lex.txt
COMMAND
- python -B ${CMAKE_SOURCE_DIR}/doc/find_rst.py --manifest-path
- ${CMAKE_CURRENT_BINARY_DIR}/rst_manifest.txt --touch
- ${CMAKE_SOURCE_DIR}/cmake_format
- DEPENDS ${CMAKE_SOURCE_DIR}/doc/find_rst.py
- BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/rst_manifest.txt
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- COMMENT "Scanning RST for cmake_format")
+ python -Bm cmake_format --dump lex ${_stage}/bits/dump-example-src.cmake >
+ ${_stage}/bits/dump-example-lex.txt
+ DEPENDS ${_stage}/bits #
+ ../../cmake_format/__main__.py #
+ ${_stage}/bits/dump-example-src.cmake
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/dump-example-lex.txt)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/dump-example-parse.txt
+ COMMAND
+ python -Bm cmake_format --dump parse
+ cmake_format/doc/bits/dump-example.cmake >
+ ${_stage}/bits/dump-example-parse.txt
+ DEPENDS ${_stage}/bits #
+ ../../cmake_format/__main__.py #
+ ${_stage}/bits/dump-example-src.cmake
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/dump-example-parse.txt)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/dump-example-layout.txt
+ COMMAND
+ python -Bm cmake_format --dump layout
+ cmake_format/doc/bits/dump-example.cmake >
+ ${_stage}/bits/dump-example-layout.txt
+ DEPENDS ${_stage}/bits #
+ ../../cmake_format/__main__.py #
+ ${_stage}/bits/dump-example-src.cmake
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/dump-example-layout.txt)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/example-in.cmake
+ COMMAND ${CMAKE_COMMAND} -E copy cmake_format/test/test_in.cmake
+ ${_stage}/bits/example-in.cmake
+ DEPENDS ${_stage}/bits #
+ ../test/test_in.cmake
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/example-in.cmake)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/example-out.cmake
+ COMMAND ${CMAKE_COMMAND} -E copy cmake_format/test/test_out.cmake
+ ${_stage}/bits/example-out.cmake
+ DEPENDS ${_stage}/bits #
+ ../test/test_out.cmake
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/example-out.cmake)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/lintimpl-table.rst
+ COMMAND python -Bm cmake_lint.gendocs table >
+ ${_stage}/bits/lintimpl-table.rst
+ DEPENDS ${_stage}/bits #
+ ../../cmake_lint/lintdb.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/lintimpl-table.rst)
+
+add_custom_command(
+ OUTPUT ${_stage}/bits/features.rst
+ COMMAND tail -n +5 cmake_format/doc/format-features.rst >
+ ${_stage}/bits/features.rst
+ DEPENDS ${_stage}/bits #
+ format-features.rst
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/bits/features.rst)
+
+add_custom_command(
+ OUTPUT ${_stage}/lint-implemented.rst
+ COMMAND python -Bm cmake_lint.gendocs reference >
+ ${_stage}/lint-implemented.rst
+ DEPENDS ${_stage}/bits #
+ ../../cmake_lint/lintdb.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/lint-implemented.rst)
+
+add_custom_command(
+ OUTPUT ${_stage}/example_rendered.html
+ COMMAND python -Bm cmake_format.annotate --format iframe
+ cmake_format/test/test_out.cmake > ${_stage}/example_rendered.html
+ DEPENDS ${_stage}/bits #
+ ../annotate.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+list(APPEND _genbits ${_stage}/example_rendered.html)
-if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
+# TODO(josh): remove this iteration for just one file.
+set(_genfiles)
+set(_insource_genfiles README.rst)
+foreach(_genfile ${_insource_genfiles})
add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/rst_manifest.txt
- DEPENDS scanrst-cmake_format_docs
- COMMENT "Stubbing RST scan for cmake_format_doc")
-endif()
+ OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${_genfile}
+ COMMAND
+ python -Bm cmake_format.doc.gendoc --bits ${_stage}/bits
+ ${CMAKE_CURRENT_SOURCE_DIR}/${_genfile}
-set(gendoc_sources_
- ${CMAKE_CURRENT_SOURCE_DIR}/README.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/configuration.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/cmake-annotate.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/cmake-format.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/cmake-lint.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/ctest-to.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/example.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/example_rendered.html
- ${CMAKE_CURRENT_SOURCE_DIR}/lint-example.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/lint-implemented.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/lint-usage.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/parse_tree.rst
- ${CMAKE_CURRENT_SOURCE_DIR}/usage.rst)
+ # TODO(josh): not every file depends on every bit, so this is overkill,
+ # but whatever... it's fine for now. We'll need more complicated code if
+ # we want to actually declare which bits each file depends on.
+ DEPENDS ${_genbits} gendoc.py
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+ list(APPEND _genfiles ${CMAKE_CURRENT_SOURCE_DIR}/${_genfile})
-add_custom_target(
- gendoc_sources-cmake_format
- COMMAND python -Bm cmake_format.doc.gendoc_sources
- DEPENDS gendoc_sources.py ${CMAKE_CURRENT_BINARY_DIR}/rst_manifest.txt
- BYPRODUCTS ${gendoc_sources_}
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- COMMENT "Generating files for cmake-format")
+ add_test(
+ NAME cmake_format-doc-verify-${_genfile}
+ COMMAND python -Bm cmake_format.doc.gendoc --verify --bits ${_stage}/bits
+ ${CMAKE_CURRENT_SOURCE_DIR}/${_genfile}
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+endforeach()
+add_custom_target(genbits-cmake_format DEPENDS ${_genbits})
+add_dependencies(test-deps genbits-cmake_format)
+add_custom_target(genfiles-cmake_format DEPENDS ${_genfiles})
+add_dependencies(gen genfiles-cmake_format)
-if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
+# copy sourcefiles from the sourcetree into the build tree so that they're all
+# accessible from one tree
+set(_copyfiles)
+set(_docsources
+ .readthedocs.yml
+ bits/dump-example.cmake
+ changelog.rst
+ cmake-annotate.rst
+ cmake-format.rst
+ cmake-lint.rst
+ configopts.rst
+ configuration.rst
+ conf.py
+ contributing.rst
+ ctest-to.rst
+ custom_parsers.rst
+ format-algorithm.rst
+ format-case_studies.rst
+ format-example.rst
+ format-features.rst
+ format-usage.rst
+ index.rst
+ installation.rst
+ lint-example.rst
+ lint-summary.rst
+ lint-usage.rst
+ modules.rst
+ parse-algorithm.rst
+ parse-automatic.rst
+ parse-tree.rst
+ release_notes.rst)
+foreach(_docsource ${_docsources})
add_custom_command(
- OUTPUT ${gendoc_sources_}
- DEPENDS gendoc_sources-cmake_format
- COMMENT "Stubbing gendocs for cmake_format_doc")
-endif()
+ OUTPUT ${_stage}/${_docsource}
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${_docsource}
+ ${_stage}/${_docsource}
+ DEPENDS ${_stage}/bits)
+ list(APPEND _copyfiles ${_stage}/${_docsource})
+endforeach()
+# For the subproject build, also copy some of the common files into the build
+# tree.
add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cmake_format_doc.stamp
+ OUTPUT ${_stage}/conf_common.py
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/doc/conf.py
+ ${_stage}/conf_common.py)
+list(APPEND _copyfiles ${_stage}/conf_common.py)
+
+add_custom_command(
+ OUTPUT ${_stage}/sphinx-static/css/cheshire_theme.css
COMMAND
- env PYTHONPATH=${CMAKE_SOURCE_DIR} sphinx-build -M html
- ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
- COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/cmake_format_doc.stamp
- DEPENDS conf.py
- ${CMAKE_CURRENT_BINARY_DIR}/rst_manifest.txt
- ${CMAKE_SOURCE_DIR}/doc/conf.py
- ${CMAKE_SOURCE_DIR}/doc/sphinx-static/css/cheshire_theme.css
- ${gendoc_sources_}
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+ ${CMAKE_COMMAND} -E copy
+ ${CMAKE_SOURCE_DIR}/doc/sphinx-static/css/cheshire_theme.css
+ ${_stage}/sphinx-static/css/cheshire_theme.css
+ DEPENDS ${_stage}/bits)
+list(APPEND _copyfiles ${_stage}/sphinx-static/css/cheshire_theme.css)
-add_custom_target(cmake_format-doc
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/cmake_format_doc.stamp)
+set(_sphinx_manifest ${_genbits} ${_copyfiles})
+
+# A list of files that should be exported to the read-the-docs repository. This
+# is used to clean the directory prior to export
+set(_rtd_manifest ${_sphinx_manifest}
+ README.rst .gitignore .readthedocs.yml rtd-requirements.txt)
+list(SORT _sphinx_manifest)
+
+# NOTE(josh): cmake 3.10 does not have list(JOIN)
+string(REPLACE ";" "\n" _manifest_text "${_sphinx_manifest}")
+
+# NOTE(josh): don't use file(WRITE) because that wont create a dependency on the
+# configure step to rerun cmake if the file is missing
+configure_file(MANIFEST.in ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST
+ NEWLINE_STYLE UNIX)
add_custom_target(
- show-cmake_format-doc
+ clean-sphinx-stage
+ DEPENDS ${_sphinx_manifest} ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST
+ COMMAND python -Bm tangent.tooling.clean_stage
+ ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST ${_stage}
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Cleaning cmake_format/doc/stage")
+
+add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
+ COMMAND env PYTHONPATH=${CMAKE_SOURCE_DIR} sphinx-build -M html ${_stage}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
+ DEPENDS clean-sphinx-stage ${_sphinx_manifest}
+ ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Building sphinx documentation for cmake_format")
+
+add_custom_target(doc-cmake_format
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
+
+add_custom_target(
+ showdoc-cmake_format
COMMAND xdg-open ${CMAKE_CURRENT_BINARY_DIR}/html/index.html
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/cmake_format_doc.stamp)
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/html/index.html)
-add_dependencies(doc cmake_format-doc)
+add_dependencies(doc doc-cmake_format)
+set_property(GLOBAL APPEND PROPERTY global_doc_files ${_sphinx_manifest})
-add_test(
- NAME cmake_format-docsources-test
- COMMAND python -Bm cmake_format.doc.gendoc_sources --verify
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
+ ${_copyfiles} ${_genbits})
+
+
+if(IS_TRAVIS_CI)
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cmake-format.deploy_key
+ COMMAND
+ # cmake-format: off
+ openssl aes-256-cbc
+ -K $ENV{encrypted_bbb694bc6401_key}
+ -iv $ENV{encrypted_bbb694bc6401_iv}
+ -in ${CMAKE_SOURCE_DIR}/tangent/tooling/deploy_keys/cmake-format.enc
+ -out ${CMAKE_CURRENT_BINARY_DIR}/cmake-format.deploy_key
+ -d
+ # cmake-format: on
+ COMMAND chmod 0600 ${CMAKE_CURRENT_BINARY_DIR}/cmake-format.deploy_key
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Decrypting cmake-format.deploy_key")
+
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cmake-tools-rtd.deploy_key
+ COMMAND
+ # cmake-format: off
+ openssl aes-256-cbc
+ -K $ENV{encrypted_4bf912706780_key}
+ -iv $ENV{encrypted_4bf912706780_iv}
+ -in ${CMAKE_SOURCE_DIR}/tangent/tooling/deploy_keys/cmake-tools-rtd.enc
+ -out ${CMAKE_CURRENT_BINARY_DIR}/cmake-tools-rtd.deploy_key
+ -d
+ # cmake-format: on
+ COMMAND chmod 0600 ${CMAKE_CURRENT_BINARY_DIR}/cmake-tools-rtd.deploy_key
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Decrypting cmake-tools-rtd.deploy_key")
+endif()
+
+set(_ssh_cmd
+ "ssh -i ${CMAKE_CURRENT_BINARY_DIR}/cmake-format.deploy_key -F /dev/null")
+
+add_custom_target(
+ push-github-pseudorelease-tag
+ COMMAND
+ python -Bm cmake_format.tools.create_pseudorelease_tag \$\${TRAVIS_BRANCH}
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/cmake-format.deploy_key
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Pushing doc artifacts to the RTD repository")
+
+
+add_custom_target(
+ push-rtd-repo
+ COMMAND
+ python -Bm cmake_format.tools.gen_rtd_requirements \$\${TRAVIS_TAG}
+ ${_version} -o ${_stage}/rtd-requirements.txt
+ COMMAND
+ # cmake-format: off
+ python -Bm tangent.tooling.sync_doc_artifacts
+ --doc-repo git@github.com:cheshirekow/cmake-tools-rtd.git
+ --repo-dir ${CMAKE_CURRENT_BINARY_DIR}/cmake-tools-rtd.git
+ --scratch-tree ${CMAKE_CURRENT_BINARY_DIR}/scratch-tree
+ --stage ${_stage}
+ --deploy-key ${CMAKE_CURRENT_BINARY_DIR}/cmake-tools-rtd.deploy_key
+ --tag \$\${TRAVIS_TAG}
+ # cmake-format: on
+ DEPENDS clean-sphinx-stage ${_sphinx_manifest}
+ ${CMAKE_CURRENT_BINARY_DIR}/cmake-tools-rtd.deploy_key
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Pushing doc artifacts to the RTD repository")
diff --git a/cmake_format/doc/MANIFEST.in b/cmake_format/doc/MANIFEST.in
new file mode 100644
index 0000000..006eee0
--- /dev/null
+++ b/cmake_format/doc/MANIFEST.in
@@ -0,0 +1 @@
+${_manifest_text}
diff --git a/cmake_format/doc/README.rst b/cmake_format/doc/README.rst
index 3049f57..47dcd19 100644
--- a/cmake_format/doc/README.rst
+++ b/cmake_format/doc/README.rst
@@ -39,7 +39,7 @@ Integrations
Usage
-----
-.. dynamic: usage-begin
+.. dynamic: format-usage-begin
.. code:: text
@@ -87,6 +87,12 @@ Usage
Various configuration options/parameters for formatting:
+ Options affecting listfile parsing:
+ --vartags [VARTAGS [VARTAGS ...]]
+ Specify variable tags.
+ --proptags [PROPTAGS [PROPTAGS ...]]
+ Specify property tags.
+
Options effecting formatting.:
--line-width LINE_WIDTH
How wide to allow formatted cmake files
@@ -241,7 +247,7 @@ Usage
utf-8. Note that cmake only claims to support utf-8 so
be careful when using anything else
-.. dynamic: usage-end
+.. dynamic: format-usage-end
-------------
Configuration
@@ -252,9 +258,9 @@ An example configuration file is given here. Additional flags and additional
kwargs will help ``cmake-format`` to break up your custom commands in a
pleasant way.
-.. dynamic: configuration-begin
+.. dynamic: configbits-begin
-.. code:: text
+.. code:: python
# ----------------------------------
# Options affecting listfile parsing
@@ -264,6 +270,12 @@ pleasant way.
# Specify structure for custom cmake functions
additional_commands = {'pkg_find': {'kwargs': {'PKG': '*'}}}
+ # Specify variable tags.
+ vartags = []
+
+ # Specify property tags.
+ proptags = []
+
# -----------------------------
# Options effecting formatting.
# -----------------------------
@@ -468,7 +480,7 @@ pleasant way.
per_command = {}
-.. dynamic: configuration-end
+.. dynamic: configbits-end
You may specify a path to a configuration file with the ``--config-file``
command line option. Otherwise, ``cmake-format`` will search the ancestry
@@ -680,7 +692,6 @@ custom command would look something like this:
.. __: https://cmake-format.rtfd.io/custom_parsers
-
.. dynamic: features-end
---------------------------------
diff --git a/cmake_format/doc/bits/dump-example.cmake b/cmake_format/doc/bits/dump-example.cmake
new file mode 100644
index 0000000..b511857
--- /dev/null
+++ b/cmake_format/doc/bits/dump-example.cmake
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.5)
+project(demo)
+if(FOO AND (BAR OR BAZ))
+ add_library(hello hello.cc)
+endif()
diff --git a/cmake_format/doc/changelog.rst b/cmake_format/doc/changelog.rst
index 3e36e50..68ba1ce 100644
--- a/cmake_format/doc/changelog.rst
+++ b/cmake_format/doc/changelog.rst
@@ -6,6 +6,35 @@ Changelog
v0.6 series
-----------
+v0.6.8
+------
+
+* Reduce packaging depependency version numbers
+* Add build rules to generate variable and property pattern lists
+* Implement lint checks on assignment/use of variables that are "close" to
+ builtins except for case.
+* Move first_token from configuration object into format context
+* Add line, col info to lex error message
+* Fix wrong root parser for FetchContent_MakeAvailable
+* Fix missing support for string integer npargs
+* Fix missing spec for derived classes of PositionalGroupNode
+* Fix on/off switch doesn't work inside a statement
+* Fix extraneous whitespace inserted before line comment in some statements
+* Add more helpful error message on failed configfile parse
+* Move documentation build to build time and push documentation artifacts
+ to an artifact repository
+
+* Closes `#162`: cmake-lint crashes when evaluating `math`
+* Closes `#163`: cmake-lint crashes when using `VERBATIM` in
+ `add_custom_target`
+* Closes `#164`: Internal error FetchContent_MakeAvailable
+* Closes: 000bf9a, 6e4ef70, 85a3985, 9a3afa6, cf4570e
+
+.. _#162: https://github.com/cheshirekow/cmake_format/issues/162
+.. _#163: https://github.com/cheshirekow/cmake_format/issues/163
+.. _#164: https://github.com/cheshirekow/cmake_format/issues/164
+
+
v0.6.7
------
@@ -24,7 +53,8 @@ v0.6.7
* Closes `#139`_: Disable wrap for custom functions
* Closes `#159`_: Missing dependency on six
-* Closes: 6ef7d0d, cf7ac49, cfa3c02, eefbde3, e75513a, f704714
+* Closes: 6ef7d0d, 9669d02, cc60267, cf7ac49, cfa3c02, eefbde3, e75513a,
+* Closes: f704714
.. _#139: https://github.com/cheshirekow/cmake_format/issues/139
.. _#159: https://github.com/cheshirekow/cmake_format/issues/159
diff --git a/cmake_format/doc/cmake-annotate.rst b/cmake_format/doc/cmake-annotate.rst
index af57b78..078299d 100644
--- a/cmake_format/doc/cmake-annotate.rst
+++ b/cmake_format/doc/cmake-annotate.rst
@@ -9,198 +9,7 @@ program which can create semantic HTML documents from parsed listfiles.
This enables, in particular, semantic highlighting for your
code documentation.
-.. dynamic: annotate-usage-begin
-
-.. code:: text
-
- usage:
- cmake-annotate [-h]
- [--format {page,stub}]
- [-o OUTFILE_PATH]
- [-c CONFIG_FILE]
- infilepath [infilepath ...]
-
- Parse cmake listfiles and re-emit them with semantic annotations in HTML.
-
- Some options regarding parsing are configurable by providing a configuration
- file. The configuration file format is the same as that used by cmake-format,
- and the same file can be used for both programs.
-
- cmake-format can spit out the default configuration for you as starting point
- for customization. Run with `--dump-config [yaml|json|python]`.
-
- positional arguments:
- infilepaths
-
- optional arguments:
- -h, --help show this help message and exit
- -v, --version show program's version number and exit
- -f {page,stub}, --format {page,stub}
- whether to output a standalone `page` complete with
- tags, or just the annotated content
- -o OUTFILE_PATH, --outfile-path OUTFILE_PATH
- Where to write the formatted file. Default is stdout.
- -c CONFIG_FILE, --config-file CONFIG_FILE
- path to configuration file
-
- Various configuration options/parameters for formatting:
-
-
- Options effecting formatting.:
- --line-width LINE_WIDTH
- How wide to allow formatted cmake files
- --tab-size TAB_SIZE How many spaces to tab for indent
- --max-subgroups-hwrap MAX_SUBGROUPS_HWRAP
- If an argument group contains more than this many sub-
- groups (parg or kwarg groups) then force it to a
- vertical layout.
- --max-pargs-hwrap MAX_PARGS_HWRAP
- If a positional argument group contains more than this
- many arguments, then force it to a vertical layout.
- --max-rows-cmdline MAX_ROWS_CMDLINE
- If a cmdline positional group consumes more than this
- many lines without nesting, then invalidate the layout
- (and nest)
- --separate-ctrl-name-with-space [SEPARATE_CTRL_NAME_WITH_SPACE]
- If true, separate flow control names from their
- parentheses with a space
- --separate-fn-name-with-space [SEPARATE_FN_NAME_WITH_SPACE]
- If true, separate function names from parentheses with
- a space
- --dangle-parens [DANGLE_PARENS]
- If a statement is wrapped to more than one line, than
- dangle the closing parenthesis on its own line.
- --dangle-align {prefix,prefix-indent,child,off}
- If the trailing parenthesis must be 'dangled' on its
- on line, then align it to this reference: `prefix`:
- the start of the statement, `prefix-indent`: the start
- of the statement, plus one indentation level, `child`:
- align to the column of the arguments
- --min-prefix-chars MIN_PREFIX_CHARS
- If the statement spelling length (including space and
- parenthesis) is smaller than this amount, then force
- reject nested layouts.
- --max-prefix-chars MAX_PREFIX_CHARS
- If the statement spelling length (including space and
- parenthesis) is larger than the tab width by more than
- this amount, then force reject un-nested layouts.
- --max-lines-hwrap MAX_LINES_HWRAP
- If a candidate layout is wrapped horizontally but it
- exceeds this many lines, then reject the layout.
- --line-ending {windows,unix,auto}
- What style line endings to use in the output.
- --command-case {lower,upper,canonical,unchanged}
- Format command names consistently as 'lower' or
- 'upper' case
- --keyword-case {lower,upper,unchanged}
- Format keywords consistently as 'lower' or 'upper'
- case
- --always-wrap [ALWAYS_WRAP [ALWAYS_WRAP ...]]
- A list of command names which should always be wrapped
- --enable-sort [ENABLE_SORT]
- If true, the argument lists which are known to be
- sortable will be sorted lexicographicall
- --autosort [AUTOSORT]
- If true, the parsers may infer whether or not an
- argument list is sortable (without annotation).
- --require-valid-layout [REQUIRE_VALID_LAYOUT]
- By default, if cmake-format cannot successfully fit
- everything into the desired linewidth it will apply
- the last, most agressive attempt that it made. If this
- flag is True, however, cmake-format will print error,
- exit with non-zero status code, and write-out nothing
-
- Options affecting comment reflow and formatting.:
- --bullet-char BULLET_CHAR
- What character to use for bulleted lists
- --enum-char ENUM_CHAR
- What character to use as punctuation after numerals in
- an enumerated list
- --first-comment-is-literal [FIRST_COMMENT_IS_LITERAL]
- If comment markup is enabled, don't reflow the first
- comment block in each listfile. Use this to preserve
- formatting of your copyright/license statements.
- --literal-comment-pattern LITERAL_COMMENT_PATTERN
- If comment markup is enabled, don't reflow any comment
- block which matches this (regex) pattern. Default is
- `None` (disabled).
- --fence-pattern FENCE_PATTERN
- Regular expression to match preformat fences in
- comments default=r'^\s*([`~]{3}[`~]*)(.*)$'
- --ruler-pattern RULER_PATTERN
- Regular expression to match rulers in comments
- default=r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'
- --explicit-trailing-pattern EXPLICIT_TRAILING_PATTERN
- If a comment line matches starts with this pattern
- then it is explicitly a trailing comment for the
- preceeding argument. Default is '#<'
- --hashruler-min-length HASHRULER_MIN_LENGTH
- If a comment line starts with at least this many
- consecutive hash characters, then don't lstrip() them
- off. This allows for lazy hash rulers where the first
- hash char is not separated by space
- --canonicalize-hashrulers [CANONICALIZE_HASHRULERS]
- If true, then insert a space between the first hash
- char and remaining hash chars in a hash ruler, and
- normalize its length to fill the column
- --enable-markup [ENABLE_MARKUP]
- enable comment markup parsing and reflow
-
- Options affecting the linter:
- --disabled-codes [DISABLED_CODES [DISABLED_CODES ...]]
- a list of lint codes to disable
- --function-pattern FUNCTION_PATTERN
- regular expression pattern describing valid function
- names
- --macro-pattern MACRO_PATTERN
- regular expression pattern describing valid macro
- names
- --global-var-pattern GLOBAL_VAR_PATTERN
- regular expression pattern describing valid names for
- variables with global scope
- --internal-var-pattern INTERNAL_VAR_PATTERN
- regular expression pattern describing valid names for
- variables with global scope (but internal semantic)
- --local-var-pattern LOCAL_VAR_PATTERN
- regular expression pattern describing valid names for
- variables with local scope
- --private-var-pattern PRIVATE_VAR_PATTERN
- regular expression pattern describing valid names for
- privatedirectory variables
- --public-var-pattern PUBLIC_VAR_PATTERN
- regular expression pattern describing valid names for
- publicdirectory variables
- --keyword-pattern KEYWORD_PATTERN
- regular expression pattern describing valid names for
- keywords used in functions or macros
- --max-conditionals-custom-parser MAX_CONDITIONALS_CUSTOM_PARSER
- In the heuristic for C0201, how many conditionals to
- match within a loop in before considering the loop a
- parser.
- --min-statement-spacing MIN_STATEMENT_SPACING
- Require at least this many newlines between statements
- --max-statement-spacing MAX_STATEMENT_SPACING
- Require no more than this many newlines between
- statements
- --max-returns MAX_RETURNS
- --max-branches MAX_BRANCHES
- --max-arguments MAX_ARGUMENTS
- --max-localvars MAX_LOCALVARS
- --max-statements MAX_STATEMENTS
-
- Options effecting file encoding:
- --emit-byteorder-mark [EMIT_BYTEORDER_MARK]
- If true, emit the unicode byte-order mark (BOM) at the
- start of the file
- --input-encoding INPUT_ENCODING
- Specify the encoding of the input file. Defaults to
- utf-8
- --output-encoding OUTPUT_ENCODING
- Specify the encoding of the output file. Defaults to
- utf-8. Note that cmake only claims to support utf-8 so
- be careful when using anything else
-
-.. dynamic: annotate-usage-end
+.. literalinclude:: bits/annotate-usage.txt
``--format stub`` will output just the marked-up listfile content. The
markup is done as ```` elements with different css classes for each
diff --git a/cmake_format/doc/cmake-format.rst b/cmake_format/doc/cmake-format.rst
index 0b0ce06..2edc8fa 100644
--- a/cmake_format/doc/cmake-format.rst
+++ b/cmake_format/doc/cmake-format.rst
@@ -8,11 +8,8 @@ like crap.
.. toctree::
:maxdepth: 2
- features
- usage
- example
- parse_tree
- parser_algorithm
- format_algorithm
- case_studies
- automatic_parsers
+ format-features
+ format-usage
+ format-example
+ format-algorithm
+ format-case_studies
diff --git a/cmake_format/doc/conf.py b/cmake_format/doc/conf.py
index 36bd306..8d5660e 100644
--- a/cmake_format/doc/conf.py
+++ b/cmake_format/doc/conf.py
@@ -1,20 +1,15 @@
import importlib
import os
-this_file = os.path.realpath(__file__)
-this_dir = os.path.dirname(this_file)
-_ = os.path.dirname(this_dir)
-root_dir = os.path.dirname(_)
-
-with open(os.path.join(root_dir, "doc/conf.py")) as infile:
+# Source the common stuff
+with open(os.path.join("./conf_common.py")) as infile:
exec(infile.read()) # pylint: disable=W0122
-project = "cmake_format"
-module = importlib.import_module(project)
+_module = importlib.import_module("cmake_format")
+# Override the project-specific stuff
+project = "cmake-tools"
docname = project + u'doc'
title = project + ' Documentation'
-version = module.VERSION
-release = module.VERSION
-
-html_static_path = [os.path.join(root_dir, "doc/sphinx-static")]
+version = _module.VERSION
+release = _module.VERSION
diff --git a/cmake_format/doc/configopts.rst b/cmake_format/doc/configopts.rst
index e588e2b..d4e646b 100644
--- a/cmake_format/doc/configopts.rst
+++ b/cmake_format/doc/configopts.rst
@@ -11,12 +11,56 @@ include
Configurations are merged and individual variables follow a latest-wins
semantic.
+--------------
+Parser options
+--------------
+
additional_commands
===================
Use this variable to specify how to parse custom cmake functions.
See :ref:`additional-cmd`.
+vartags
+=======
+
+Specify a mapping of variable patterns (python regular expression) to a list
+of tags. Any time a a variable matching this pattern is encountered the tags
+can be used to affect the parsing/formatting. For example:
+
+.. code::
+
+ vartags = [
+ (".*_COMMAND", ["cmdline"])
+ ]
+
+Specifies that any variable ending in ``_COMMAND`` be tagged as ``cmdline``.
+This will affect the formatting by preventing the arguments from being
+vertically wrapped.
+
+Note: this particular rule is builtin so you do not need to include this in
+your configuration. Use the configuration variable to add new rules.
+
+proptags
+========
+
+Specify a mapping of property patterns (python regular expression) to a list
+of tags. Any time a a property matching this pattern is encountered the tags
+can be used to affect the parsing/formatting. For example:
+
+.. code::
+
+ proptags = [
+ (".*_DIRECTORIES", ["file-list"])
+ ]
+
+Specifies that any property ending in ``_DIRECTORIES`` be tagged as
+``file-list``. In the future this may affect formatting by allowing arguments
+to be sorted (but currently has no effect).
+
+Note: this particular rule is builtin so you do not need to include this in
+your configuration. Use the configuration variable to add new rules.
+
--------------------------
General Formatting Options
--------------------------
diff --git a/cmake_format/doc/configuration.rst b/cmake_format/doc/configuration.rst
index 0489a44..4fb4510 100644
--- a/cmake_format/doc/configuration.rst
+++ b/cmake_format/doc/configuration.rst
@@ -34,220 +34,4 @@ configuration ``stdout`` and use that as a starting point.
Here is an example python-style configuration file with the default options and
help-text. Some detailed examples can be found at :ref:`configopts`.
-.. dynamic: configuration-begin
-
-.. code:: text
-
- # ----------------------------------
- # Options affecting listfile parsing
- # ----------------------------------
- with section("parse"):
-
- # Specify structure for custom cmake functions
- additional_commands = {'pkg_find': {'kwargs': {'PKG': '*'}}}
-
- # -----------------------------
- # Options effecting formatting.
- # -----------------------------
- with section("format"):
-
- # How wide to allow formatted cmake files
- line_width = 80
-
- # How many spaces to tab for indent
- tab_size = 2
-
- # If an argument group contains more than this many sub-groups (parg or kwarg
- # groups) then force it to a vertical layout.
- max_subgroups_hwrap = 2
-
- # If a positional argument group contains more than this many arguments, then
- # force it to a vertical layout.
- max_pargs_hwrap = 6
-
- # If a cmdline positional group consumes more than this many lines without
- # nesting, then invalidate the layout (and nest)
- max_rows_cmdline = 2
-
- # If true, separate flow control names from their parentheses with a space
- separate_ctrl_name_with_space = False
-
- # If true, separate function names from parentheses with a space
- separate_fn_name_with_space = False
-
- # If a statement is wrapped to more than one line, than dangle the closing
- # parenthesis on its own line.
- dangle_parens = False
-
- # If the trailing parenthesis must be 'dangled' on its on line, then align it
- # to this reference: `prefix`: the start of the statement, `prefix-indent`:
- # the start of the statement, plus one indentation level, `child`: align to
- # the column of the arguments
- dangle_align = 'prefix'
-
- # If the statement spelling length (including space and parenthesis) is
- # smaller than this amount, then force reject nested layouts.
- min_prefix_chars = 4
-
- # If the statement spelling length (including space and parenthesis) is larger
- # than the tab width by more than this amount, then force reject un-nested
- # layouts.
- max_prefix_chars = 10
-
- # If a candidate layout is wrapped horizontally but it exceeds this many
- # lines, then reject the layout.
- max_lines_hwrap = 2
-
- # What style line endings to use in the output.
- line_ending = 'unix'
-
- # Format command names consistently as 'lower' or 'upper' case
- command_case = 'canonical'
-
- # Format keywords consistently as 'lower' or 'upper' case
- keyword_case = 'unchanged'
-
- # A list of command names which should always be wrapped
- always_wrap = []
-
- # If true, the argument lists which are known to be sortable will be sorted
- # lexicographicall
- enable_sort = True
-
- # If true, the parsers may infer whether or not an argument list is sortable
- # (without annotation).
- autosort = False
-
- # By default, if cmake-format cannot successfully fit everything into the
- # desired linewidth it will apply the last, most agressive attempt that it
- # made. If this flag is True, however, cmake-format will print error, exit
- # with non-zero status code, and write-out nothing
- require_valid_layout = False
-
- # A dictionary mapping layout nodes to a list of wrap decisions. See the
- # documentation for more information.
- layout_passes = {}
-
- # ------------------------------------------------
- # Options affecting comment reflow and formatting.
- # ------------------------------------------------
- with section("markup"):
-
- # What character to use for bulleted lists
- bullet_char = '*'
-
- # What character to use as punctuation after numerals in an enumerated list
- enum_char = '.'
-
- # If comment markup is enabled, don't reflow the first comment block in each
- # listfile. Use this to preserve formatting of your copyright/license
- # statements.
- first_comment_is_literal = False
-
- # If comment markup is enabled, don't reflow any comment block which matches
- # this (regex) pattern. Default is `None` (disabled).
- literal_comment_pattern = None
-
- # Regular expression to match preformat fences in comments
- # default=r'^\s*([`~]{3}[`~]*)(.*)$'
- fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
-
- # Regular expression to match rulers in comments
- # default=r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'
- ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
-
- # If a comment line matches starts with this pattern then it is explicitly a
- # trailing comment for the preceeding argument. Default is '#<'
- explicit_trailing_pattern = '#<'
-
- # If a comment line starts with at least this many consecutive hash
- # characters, then don't lstrip() them off. This allows for lazy hash rulers
- # where the first hash char is not separated by space
- hashruler_min_length = 10
-
- # If true, then insert a space between the first hash char and remaining hash
- # chars in a hash ruler, and normalize its length to fill the column
- canonicalize_hashrulers = True
-
- # enable comment markup parsing and reflow
- enable_markup = True
-
- # ----------------------------
- # Options affecting the linter
- # ----------------------------
- with section("lint"):
-
- # a list of lint codes to disable
- disabled_codes = []
-
- # regular expression pattern describing valid function names
- function_pattern = '[0-9a-z_]+'
-
- # regular expression pattern describing valid macro names
- macro_pattern = '[0-9A-Z_]+'
-
- # regular expression pattern describing valid names for variables with global
- # scope
- global_var_pattern = '[0-9A-Z][0-9A-Z_]+'
-
- # regular expression pattern describing valid names for variables with global
- # scope (but internal semantic)
- internal_var_pattern = '_[0-9A-Z][0-9A-Z_]+'
-
- # regular expression pattern describing valid names for variables with local
- # scope
- local_var_pattern = '[0-9a-z_]+'
-
- # regular expression pattern describing valid names for privatedirectory
- # variables
- private_var_pattern = '_[0-9a-z_]+'
-
- # regular expression pattern describing valid names for publicdirectory
- # variables
- public_var_pattern = '[0-9A-Z][0-9A-Z_]+'
-
- # regular expression pattern describing valid names for keywords used in
- # functions or macros
- keyword_pattern = '[0-9A-Z_]+'
-
- # In the heuristic for C0201, how many conditionals to match within a loop in
- # before considering the loop a parser.
- max_conditionals_custom_parser = 2
-
- # Require at least this many newlines between statements
- min_statement_spacing = 1
-
- # Require no more than this many newlines between statements
- max_statement_spacing = 1
- max_returns = 6
- max_branches = 12
- max_arguments = 5
- max_localvars = 15
- max_statements = 50
-
- # -------------------------------
- # Options effecting file encoding
- # -------------------------------
- with section("encode"):
-
- # If true, emit the unicode byte-order mark (BOM) at the start of the file
- emit_byteorder_mark = False
-
- # Specify the encoding of the input file. Defaults to utf-8
- input_encoding = 'utf-8'
-
- # Specify the encoding of the output file. Defaults to utf-8. Note that cmake
- # only claims to support utf-8 so be careful when using anything else
- output_encoding = 'utf-8'
-
- # -------------------------------------
- # Miscellaneous configurations options.
- # -------------------------------------
- with section("misc"):
-
- # A dictionary containing any per-command configuration overrides. Currently
- # only `command_case` is supported.
- per_command = {}
-
-
-.. dynamic: configuration-end
+.. literalinclude:: bits/configbits.py
diff --git a/cmake_format/doc/ctest-to.rst b/cmake_format/doc/ctest-to.rst
index 0cff3f7..135393c 100644
--- a/cmake_format/doc/ctest-to.rst
+++ b/cmake_format/doc/ctest-to.rst
@@ -9,27 +9,7 @@ generate a more structured representation of the test spec.
Usage
-----
-.. dynamic: ctest-to-usage-begin
-
-.. code:: text
-
- usage: ctest-to [-h] [--log-level {debug,info,warning,error}] [--json | --xml]
- [directory]
-
- Parse ctest testfiles and re-emit the test specification in a more structured
- format.
-
- positional arguments:
- directory
-
- optional arguments:
- -h, --help show this help message and exit
- --log-level {debug,info,warning,error}
- --json
- --xml
-
-.. dynamic: ctest-to-usage-end
-
+.. literalinclude:: bits/ctest-to-usage.txt
-------
Example
diff --git a/cmake_format/doc/docsources_test.py b/cmake_format/doc/docsources_test.py
deleted file mode 100644
index 2aacdd5..0000000
--- a/cmake_format/doc/docsources_test.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import os
-import unittest
-import subprocess
-import sys
-import tempfile
-
-
-class TestDocSources(unittest.TestCase):
- """
- Ensure that dynamic documentation content is up-to-date
- """
-
- def test_docsources_uptodate(self):
- rootdir = os.path.realpath(__file__)
- for _ in range(3):
- rootdir = os.path.dirname(rootdir)
-
- with tempfile.NamedTemporaryFile(delete=False) as errlog:
- errlogpath = errlog.name
- result = subprocess.call(
- [sys.executable, "-Bm", "cmake_format.doc.gendoc_sources",
- "--verify"],
- cwd=rootdir, stderr=errlog)
- with open(errlogpath, "r") as infile:
- errmsg = "Error log: \n" + infile.read()
- os.unlink(errlogpath)
- self.assertEqual(0, result, errmsg)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/cmake_format/doc/example_rendered.html b/cmake_format/doc/example_rendered.html
index 3f10c46..4a7c914 100644
--- a/cmake_format/doc/example_rendered.html
+++ b/cmake_format/doc/example_rendered.html
@@ -1,4 +1,3 @@
-
@@ -158,13 +157,4 @@
-
-
-
-
+