diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index e588b01..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: auto-generate-readme -on: - push: - branches: [master] - pull_request: - branches: [master] - -jobs: - auto-generate-readme: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v2 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - - name: Install Python3 - uses: actions/setup-python@v2 - with: - python-version: '3.7' - - name: Update README - run: python auto-generate-readme.py - - name: Commit - run: | - git config --global user.name 'Github Action Bot' - git config --global user.email 'bot@example.com' - git add -u . - git commit -m 'Update README' || echo "No changes to commit" - git push origin || echo "No changes to push" diff --git a/auto-generate-readme.py b/auto-generate-readme.py deleted file mode 100644 index 0bb683e..0000000 --- a/auto-generate-readme.py +++ /dev/null @@ -1,89 +0,0 @@ -from pathlib import Path - - -class MarkdownParser(): - - def __init__(self, text): - self.text = text - self.lines = text.split('\n') - - def title(self): - return self.lines[0].split(' ')[1] - - def header(self, name, level, include_header=False): - start = False - end = False - content = [] - mark = '#' * level - for line in self.lines: - if start and not end: - end |= (f'{mark} ' in line[:(level + 1)]) and (not f'{mark} {name}' in line) - if end: - start = False - else: - content.append(line) - else: - start = (f'{mark} {name}' in line) - if start: - end = False - if include_header: - content.append(line) - - content = '\n'.join(content) - return content - - def overview(self): - overview = self.header('Overview', 2) - overview = overview.split('\n') - overview = '\n'.join(overview[1:]) # remove the first line - return overview - - def features(self): - return self.header('C++', 2, True) - - -def combine(text, parsers): - overview = '' - features = '' - title = '' - for p in parsers: - title += p.title().replace('C++', '') + '/' - overview += p.overview() + '\n' - features += p.features() + '\n' - - title = title[:-1] - overview = overview.replace('README.md#', '#') - features = features.replace('README.md#', '#') - - text = text.replace('# C++\n', f'# C++{title}\n') - text = text.replace(f'', overview) - text = text.replace(f'', features) - - return text - - -def main(): - src_dir = Path(__file__).parent - parsers = [] - - srcs = list(src_dir.glob('CPP*.md')) - srcs.sort(reverse=True) - for file in srcs: - with open(file, 'r') as fp: - text = fp.read() - p = MarkdownParser(text) - parsers.append(p) - - template_file = src_dir / 'readme-template.md' - with open(template_file, 'r') as fp: - text = fp.read() - - text = combine(text, parsers) - - readme_file = src_dir / 'README.md' - with open(readme_file, 'w') as fp: - fp.write(text) - - -if __name__ == '__main__': - main() diff --git a/readme-template.md b/readme-template.md deleted file mode 100644 index fc54b91..0000000 --- a/readme-template.md +++ /dev/null @@ -1,26 +0,0 @@ -# C++ - -## Overview - - - - - -## Acknowledgements -* [cppreference](http://en.cppreference.com/w/cpp) - especially useful for finding examples and documentation of new library features. -* [C++ Rvalue References Explained](http://thbecker.net/articles/rvalue_references/section_01.html) - a great introduction I used to understand rvalue references, perfect forwarding, and move semantics. -* [clang](http://clang.llvm.org/cxx_status.html) and [gcc](https://gcc.gnu.org/projects/cxx-status.html)'s standards support pages. Also included here are the proposals for language/library features that I used to help find a description of, what it's meant to fix, and some examples. -* [Compiler explorer](https://godbolt.org/) -* [Scott Meyers' Effective Modern C++](https://www.amazon.com/Effective-Modern-Specific-Ways-Improve/dp/1491903996) - highly recommended series of books! -* [Jason Turner's C++ Weekly](https://www.youtube.com/channel/UCxHAlbZQNFU2LgEtiqd2Maw) - nice collection of C++-related videos. -* [What can I do with a moved-from object?](http://stackoverflow.com/questions/7027523/what-can-i-do-with-a-moved-from-object) -* [What are some uses of decltype(auto)?](http://stackoverflow.com/questions/24109737/what-are-some-uses-of-decltypeauto) - -## Author -Anthony Calandra - -## Content Contributors -See: https://github.com/AnthonyCalandra/modern-cpp-features/graphs/contributors - -## License -MIT