diff --git a/README.md b/README.md index 890c9406..b71fdfac 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ cibuildwheel [Documentation](https://cibuildwheel.readthedocs.org) + + Python wheels are great. Building them across **Mac, Linux, Windows**, on **multiple versions of Python**, is not. `cibuildwheel` is here to help. `cibuildwheel` runs on your CI server - currently it supports Azure Pipelines, Travis CI, AppVeyor, and CircleCI - and it builds and tests your wheels across all of your platforms. @@ -34,6 +36,8 @@ Usage `cibuildwheel` is not intended to run on your development machine. Because it uses system Python from Python.org it will try to install packages globally - not what you expect from a build tool! Instead, isolated CI services like Travis CI, CircleCI, Azure Pipelines and AppVeyor are ideal. + + Example setup ------------- diff --git a/docs/index.md b/docs/index.md index ff963eb8..6ff84d00 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,3 +4,9 @@ Home Welcome to the cibuildwheel docs. To get started, head over to the [setup guide](setup.md). + +{% + includemarkdown "../README.md" + start="" + end="" +%} diff --git a/docs/mkdocs_include_markdown_plugin/mkdocs_include_markdown_plugin/__init__.py b/docs/mkdocs_include_markdown_plugin/mkdocs_include_markdown_plugin/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/docs/mkdocs_include_markdown_plugin/mkdocs_include_markdown_plugin/plugin.py b/docs/mkdocs_include_markdown_plugin/mkdocs_include_markdown_plugin/plugin.py new file mode 100644 index 00000000..289c7a8e --- /dev/null +++ b/docs/mkdocs_include_markdown_plugin/mkdocs_include_markdown_plugin/plugin.py @@ -0,0 +1,53 @@ +import mkdocs, re, os, io, cgi +from pprint import pprint + +TAG_REGEX_PATTERN = re.compile( + r''' + {% # opening tag + \s* + includemarkdown # directive name + \s+ + "(?P[^"]+)" # "filename" + (?:\s+start="(?P[^"]+)")? # optional start expression + (?:\s+end="(?P[^"]+)")? # optional end expression + \s* + %} # closing tag + ''', + flags=re.VERBOSE, +) + +class ImportMarkdownPlugin(mkdocs.plugins.BasePlugin): + def on_page_markdown(self, markdown, page, **kwargs): + page_src_path = page.file.abs_src_path + + def found_import_markdown_tag(match): + filename = match.group('filename') + start = match.group('start') + end = match.group('end') + print('got a match', filename, start, end) + + file_path_abs = os.path.join(os.path.dirname(page_src_path), filename) + + if not os.path.exists(file_path_abs): + raise ValueError('file not found', filename) + + with io.open(file_path_abs, encoding='utf8') as f: + text_to_include = f.read() + + if start: + _, _, text_to_include = text_to_include.partition(start) + + if end: + text_to_include, _, _ = text_to_include.partition(end) + + return ( + '' % ( + filename, cgi.escape(start), cgi.escape(end) + ) + + text_to_include + + '' + ) + + markdown = re.sub(TAG_REGEX_PATTERN, found_import_markdown_tag, markdown) + return markdown + \ No newline at end of file diff --git a/docs/mkdocs_include_markdown_plugin/setup.py b/docs/mkdocs_include_markdown_plugin/setup.py new file mode 100644 index 00000000..0f8b6a18 --- /dev/null +++ b/docs/mkdocs_include_markdown_plugin/setup.py @@ -0,0 +1,15 @@ +from setuptools import setup + +setup( + name='mkdocs_include_markdown_plugin', + version='1.0', + author='Joe Rickerby', + license='Apache 2', + packages=['mkdocs_include_markdown_plugin'], + entry_points={ + 'mkdocs.plugins': [ + 'importmarkdown = mkdocs_include_markdown_plugin.plugin:ImportMarkdownPlugin', + ] + }, + zip_safe=False +) diff --git a/mkdocs.yml b/mkdocs.yml index 2c9caadc..a0ada14e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -27,3 +27,6 @@ markdown_extensions: permalink: True - attr_list - admonition + +plugins: + - importmarkdown