Modify language list in place and add count

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
Richie Bendall
2020-07-01 17:02:15 +12:00
parent 0175d0bf66
commit d970061863
5 changed files with 49 additions and 52 deletions

View File

@@ -4,12 +4,12 @@
#### Naming #### Naming
The file should be name according to the language it was written. The name shouldn't be abbreviated too far (`Javascript.js` instead of `JS.js`) and it shouldn't be abbreviated to little (`CSS.css` instead of `Cascading Style Sheets.css`). Additionally, hyphens should be used instead of spaces (`Objective-C.m` instead of `Objective C.m`). The file should be named according to the language it was written. The name shouldn't be abbreviated too far (`Javascript.js` instead of `JS.js`) and it shouldn't be abbreviated to little (`CSS.css` instead of `Cascading Style Sheets.css`). Additionally, hyphens should be used instead of spaces (`Objective-C.m` instead of `Objective C.m`).
#### Contents #### Contents
The code in the file should be the simplest or most straightforward way to print/display/show `Hello World` exactly once in the language used. Input from the user shouldn't be asked for where possible and a newline should only be printed when nessesary. The code in the file should be the simplest or most straightforward way to print/display/show `Hello World` exactly once in the language used. Input from the user shouldn't be asked for where possible and a newline should only be printed when necessary.
### Updating README ### Updating README
All changes to the README should be done in `README_nolist.md` instead and `list_langs.py` (Python 3.6+) should be run to automatically update the main one. `update_list.py` (Python 3.6+) should be run to automatically update the language list.

View File

@@ -1,19 +1,15 @@
Hello World! # Hello World
=============
> Inspired by [The Hello World Collection](https://helloworldcollection.github.io/). Hello world in every computer language.
#### Hello world in every computer language.
As I watch the collection expand, this project has blown up more than I ever thought possible. As I watch the collection expand, this project has blown up more than I ever thought possible.
Thanks to everyone who continues to contribute, new languages are created every day! Thanks to everyone who continues to contribute; new languages are created every day!
Make sure to see [CONTRIBUTING.md](/CONTRIBUTING.md) for instructions on contributing to the project! Make sure to see [CONTRIBUTING.md](/CONTRIBUTING.md) for instructions on contributing to the project!
Spin-Off project smartly suggested and implemented by [@zenware](https://github.com/zenware): <!--Languages start-->
Meet [FizzBuzz](https://github.com/zenware/FizzBuzz), the evolution of [hello-world](https://github.com/leachim6/hello-world). ## Languages (661 total)
### This repository currently contains "Hello World" programs in the following languages:
* [05Ab1E](%23/05AB1E) * [05Ab1E](%23/05AB1E)
* [0815](%23/0815.0815) * [0815](%23/0815.0815)
* [1C Enterprise](%23/1c-enterprise) * [1C Enterprise](%23/1c-enterprise)
@@ -484,7 +480,7 @@ Meet [FizzBuzz](https://github.com/zenware/FizzBuzz), the evolution of [hello-wo
* [Profan](p/profan) * [Profan](p/profan)
* [Prolog](p/prolog.pro) * [Prolog](p/prolog.pro)
* [Promela](p/promela.pml) * [Promela](p/promela.pml)
* [ProvideX](p/providex.vim) * [Providex](p/providex.vim)
* [Pug](p/pug.pug) * [Pug](p/pug.pug)
* [Pure Data](p/pure_data.pd) * [Pure Data](p/pure_data.pd)
* [Purebasic](p/purebasic.pb) * [Purebasic](p/purebasic.pb)
@@ -675,3 +671,9 @@ Meet [FizzBuzz](https://github.com/zenware/FizzBuzz), the evolution of [hello-wo
* [Zombie](z/zombie.zombie) * [Zombie](z/zombie.zombie)
* [Zonnon](z/zonnon.znn) * [Zonnon](z/zonnon.znn)
* [Zsh](z/zsh.zsh) * [Zsh](z/zsh.zsh)
<!--Languages end-->
## Related
- [FizBuzz](https://github.com/zenware/FizzBuzz)
- [The Hello World Collection](https://helloworldcollection.github.io/).

View File

@@ -1,14 +0,0 @@
Hello World!
=============
> Inspired by [The Hello World Collection](https://helloworldcollection.github.io/).
#### Hello world in every computer language.
As I watch the collection expand, this project has blown up more than I ever thought possible.
Thanks to everyone who continues to contribute, new languages are created every day!
Make sure to see [CONTRIBUTING.md](/CONTRIBUTING.md) for instructions on contributing to the project!
Spin-Off project smartly suggested and implemented by [@zenware](https://github.com/zenware):
Meet [FizzBuzz](https://github.com/zenware/FizzBuzz), the evolution of [hello-world](https://github.com/leachim6/hello-world).

View File

@@ -1,25 +0,0 @@
#!/usr/bin/env python3
import os
import posixpath
from urllib.parse import quote
readme = open('README.md', 'w', encoding="utf-8")
# Copy template to README
with open('README_nolist.md', 'r') as file:
for line in file:
readme.write(line)
# Write title
readme.write('\n### This repository currently contains "Hello World" programs in the following languages:\n')
# List the available languages
for directory in sorted(os.listdir('.')):
if not (directory == '.' or directory == '..' or directory[0] == '.' or os.path.isfile(directory)):
for filename in sorted(os.listdir(directory), key=lambda s: s.lower()):
if os.path.isfile(os.path.join(directory, filename)):
language = os.path.splitext(filename)[0].replace('-', ' ').replace('_', ' ').title()
readme.write(f'* [{language}]({posixpath.join(quote(directory), quote(filename))})\n')
readme.close()

34
update_list.py Normal file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env python3
import os
import posixpath
from urllib.parse import quote
import re
def regexReplace(string, search, replacement):
return re.compile(search).sub(replacement, string)
languageCount = 0
languagesText = ""
# List the available languages
for directory in sorted(os.listdir('.')):
if not (directory == '.' or directory == '..' or directory[0] == '.' or os.path.isfile(directory)):
for filename in sorted(os.listdir(directory), key=lambda s: s.lower()):
if os.path.isfile(os.path.join(directory, filename)):
language = os.path.splitext(filename)[0].replace(
'-', ' ').replace('_', ' ').title()
languagesText += f'* [{language}]({posixpath.join(quote(directory), quote(filename))})\n'
languageCount += 1
result = f"""<!--Languages start-->
## Languages ({languageCount} total)
{languagesText}<!--Languages end-->"""
readmeContents = open('README.md', 'r', encoding="utf-8").read()
open('README.md', 'w', encoding="utf-8").write(regexReplace(
readmeContents, r"<!--Languages start-->(.|\n)*<!--Languages end-->", result))