Skip to content

Commit

Permalink
Modify language list in place and add count
Browse files Browse the repository at this point in the history
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
  • Loading branch information
Richienb committed Jul 1, 2020
1 parent 0175d0b commit d970061
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 52 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -4,12 +4,12 @@

#### 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

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

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.
22 changes: 12 additions & 10 deletions README.md
@@ -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.
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!

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).
<!--Languages start-->
## Languages (661 total)

### This repository currently contains "Hello World" programs in the following languages:
* [05Ab1E](%23/05AB1E)
* [0815](%23/0815.0815)
* [1C Enterprise](%23/1c-enterprise)
Expand Down Expand Up @@ -484,7 +480,7 @@ Meet [FizzBuzz](https://github.com/zenware/FizzBuzz), the evolution of [hello-wo
* [Profan](p/profan)
* [Prolog](p/prolog.pro)
* [Promela](p/promela.pml)
* [ProvideX](p/providex.vim)
* [Providex](p/providex.vim)
* [Pug](p/pug.pug)
* [Pure Data](p/pure_data.pd)
* [Purebasic](p/purebasic.pb)
Expand Down Expand Up @@ -675,3 +671,9 @@ Meet [FizzBuzz](https://github.com/zenware/FizzBuzz), the evolution of [hello-wo
* [Zombie](z/zombie.zombie)
* [Zonnon](z/zonnon.znn)
* [Zsh](z/zsh.zsh)
<!--Languages end-->

## Related

- [FizBuzz](https://github.com/zenware/FizzBuzz)
- [The Hello World Collection](https://helloworldcollection.github.io/).
14 changes: 0 additions & 14 deletions README_nolist.md

This file was deleted.

25 changes: 0 additions & 25 deletions list_langs.py

This file was deleted.

34 changes: 34 additions & 0 deletions update_list.py
@@ -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))

0 comments on commit d970061

Please sign in to comment.