Skip to content

Commit a67c92b

Browse files
committed
Merge branch 'develop'
2 parents fe5842b + eb1dc2c commit a67c92b

File tree

2,096 files changed

+76724
-83436
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,096 files changed

+76724
-83436
lines changed

.gitattributes

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
*.TXT text eol=crlf
1919

2020
# Denote all files that are truly binary and should not be modified.
21-
test/correctness/** binary
22-
test/correctness/*/*/* binary
23-
test/correctness/* binary
24-
test/correctness/*/* binary
2521
test/**/*.BAS binary
2622
test/**/*.TXT binary
23+
test/basic/** binary
24+
tests/**/*.BAS binary
25+
tests/**/*.TXT binary
26+
tests/basic/** binary

HACKING.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@ The following packages are needed or recommended when installing PC-BASIC:
1313

1414
| Package | OS | Status | Used for
1515
|-------------------------------------------------------------------------------|--------------------|--------------|----------------------------------------
16-
| [Python 2.7.12](https://www.python.org/downloads/release/python-2712/) | all | required |
16+
| [Python 3.5.10 or later](https://www.python.org/downloads/) | all | required |
1717
| [SDL2](https://www.libsdl.org/download-2.0.php) | all | recommended | sound and graphics
18-
| [NumPy](https://sourceforge.net/projects/numpy/files/) | all | recommended | sound and graphics
19-
| [PySerial 3.4](https://pypi.python.org/pypi/pyserial) | all | optional | physical or emulated serial port access
20-
| [PyParallel](https://sourceforge.net/projects/pyserial/files/pyparallel/0.2/) | Windows, Linux | optional | physical parallel port access
21-
| [PyGame 1.9.3](http://www.pygame.org) | all | optional | sound and graphics (PyGame interface)
22-
| [PyAudio](http://people.csail.mit.edu/hubert/pyaudio/) | all | optional | sound (PortAudio engine)
18+
| [PyAudio](http://people.csail.mit.edu/hubert/pyaudio/) | all | optional | sound when using text-based interface
19+
| [PySerial 3.4](https://github.com/pyserial/pyserial) | all | optional | physical or emulated serial port access
20+
| [PyParallel](https://github.com/pyserial/pyparallel) | Windows, Linux | optional | physical parallel port access
21+
| [PyGame 1.9.3](http://www.pygame.org) | all | deprecated | sound and graphics
2322

2423

2524
`setuptools` and `pip` are included with Python.
2625
Once you have a working Python installation, most dependencies can be installed with `pip`:
2726

28-
pip install numpy pygame pyaudio pyserial
27+
pip install pyaudio pyserial
2928

3029
To use the graphical interface, you will also need to install the [SDL2](https://www.libsdl.org/download-2.0.php) library.
3130
Install the library in your OS's standard location for libraries.
@@ -41,6 +40,8 @@ Note that most modern machines do not actually have parallel ports. If you have
4140
download and install PyParallel from the link above. Although a `pyparallel` package exists in on PyPI, at present this does not work
4241
as essential libraries are missing.
4342

43+
Alternatively to the latest Python, for now PC-BASIC remains compatible with [Python 2.7](https://www.python.org/downloads/release/python-2718/).
44+
4445

4546
#### External tools ####
4647
PC-BASIC employs the following external command-line tools, if available:
@@ -65,6 +66,7 @@ The following additional packages are used for development, testing and packagin
6566
| [Prince](https://www.princexml.com/download/) | all | documentation
6667
| [`pylint`](https://pypi.python.org/pypi/pylint/1.7.6) | all | testing
6768
| [`coverage`](https://pypi.python.org/pypi/coverage) | all | testing
69+
| [`colorama`](https://pypi.python.org/pypi/colorama) | Windows | testing
6870
| [`wheel`](https://pypi.python.org/pypi/wheel) | all | packaging
6971
| [`twine`](https://pypi.python.org/pypi/twine) | all | packaging
7072
| [`Pillow`](https://python-pillow.org/) | all | packaging
@@ -127,13 +129,6 @@ Those who prefer to use the [MinGW](http://mingw.org/) GCC compiler, follow thes
127129
gcc -shared -o SDL2_gfx.dll *.o SDL2.dll
128130

129131

130-
#### Installing with PyGame ####
131-
The preferred graphical interface is SDL2. However, a PyGame interface is also available.
132-
133-
The 1.9.1 release of PyGame, currently still standard on some distributions (e.g. Ubuntu 16.04 LTS),
134-
unfortunately contains a few bugs that have been resolved in newer releases. Please use the latest
135-
PyGame release from pygame.org, or install with `pip install pygame`.
136-
137132
#### Contributing code ####
138133

139134
The current code base of PC-BASIC was written by a single author, Rob Hagemans.

THANKS.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,18 @@ Avid testers and bug hunters
3131

3232
PC-BASIC incorporates code derived from other projects, in particular:
3333

34-
* **J-L Morel**'s [Win32::Console::ANSI](http://search.cpan.org/~jlmorel/Win32-Console-ANSI-1.11/lib/Win32/Console/ANSI.pm)
35-
* **Valentin Lab**'s [win_subprocess.py](https://gist.github.com/vaab/2ad7051fc193167f15f85ef573e54eb9)
3634
* **Marcus von Appen**'s [PySDL2](https://pysdl2.readthedocs.org/en/latest/)
35+
* **Jonathan Hartley**'s [colorama](https://github.com/tartley/colorama)
36+
* **Valentin Lab**'s [win_subprocess.py](https://gist.github.com/vaab/2ad7051fc193167f15f85ef573e54eb9)
3737

3838
PC-BASIC depends on the following open-source projects:
3939

4040
* [Python](http://www.python.org)
4141
* [Setuptools](https://pypi.python.org/pypi/setuptools)
42-
* [NumPy](http://www.numpy.org)
43-
* [PySerial](https://github.com/pyserial/pyserial)
44-
* [PyParallel](https://github.com/pyserial/pyparallel)
4542
* [Simple DirectMedia Layer (SDL)](http://www.libsdl.org)
4643
* [SDL2_gfx](http://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/)
47-
* [PyGame](http://www.pygame.org)
44+
* [PySerial](https://github.com/pyserial/pyserial)
45+
* [PyParallel](https://github.com/pyserial/pyparallel)
4846
* [PyAudio](http://people.csail.mit.edu/hubert/pyaudio/)
4947

5048

@@ -54,8 +52,11 @@ PC-BASIC would not have been what it is without the following open-source projec
5452
which it has depended on in the past:
5553

5654
* **Tom Rothamel**'s [PyGame Subset for Android](https://web.archive.org/web/20150712040220/http://pygame.renpy.org/) (superseded by [RAPT](http://www.renpy.org/doc/html/android.html))
55+
* **J-L Morel**'s [Win32::Console::ANSI](http://search.cpan.org/~jlmorel/Win32-Console-ANSI-1.11/lib/Win32/Console/ANSI.pm)
5756
* [Python for Windows Extensions (PyWin32)](https://sourceforge.net/projects/pywin32/)
5857
* [PExpect](http://pexpect.readthedocs.org/en/latest/)
58+
* [PyGame](http://www.pygame.org)
59+
* [NumPy](http://www.numpy.org)
5960

6061

6162
### Technical Documentation

docsrc/__init__.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
from .makeusage import makeusage
2-
from .makeman import makeman
3-
from .makedoc import makedoc
1+
"""
2+
PC-BASIC - docsrc
3+
Documentation builder and source
4+
5+
(c) 2013--2020 Rob Hagemans
6+
This file is released under the GNU GPL version 3 or later.
7+
"""
8+
9+
from .usage import makeusage
10+
from .man import makeman
11+
from .doc import makedoc
412

513
def build_docs():
14+
"""Build all documentation files."""
615
makeusage()
716
makeman()
817
makedoc()

docsrc/makedoc.py renamed to docsrc/doc.py

Lines changed: 71 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
1-
import sys
1+
"""
2+
PC-BASIC - docsrc.doc
3+
HTML documentation builder
4+
5+
(c) 2013--2020 Rob Hagemans
6+
This file is released under the GNU GPL version 3 or later.
7+
"""
8+
29
import os
3-
from os import path
4-
import shutil
5-
from io import StringIO
10+
import json
611
from datetime import datetime
7-
from io import open
12+
from io import StringIO, open
813

914
from lxml import etree
1015
import markdown
1116
from markdown.extensions.toc import TocExtension
1217
import markdown.extensions.headerid
1318

14-
# obtain metadata without importing the package (to avoid breaking setup)
15-
with open(
16-
path.join(path.abspath(path.dirname(__file__)), '..', 'pcbasic', 'metadata.py'),
17-
encoding='utf-8') as f:
18-
exec(f.read())
19+
# we're not being called from setup.py install, so we can simply import pcbasic
20+
from pcbasic.basic import VERSION
1921

20-
basepath = os.path.dirname(os.path.realpath(__file__))
2122

23+
BASEPATH = os.path.dirname(os.path.realpath(__file__))
2224

23-
def mdtohtml(md_file, outf, prefix='', baselevel=1):
25+
with open(os.path.join(BASEPATH, '..', 'setup.json'), encoding='utf-8') as setup_data:
26+
SETUP_DATA = json.load(setup_data)
27+
28+
29+
def _md_to_html(md_file, outf, prefix='', baselevel=1):
30+
"""Convert markdown to html."""
2431
with open(md_file, 'r', encoding='utf-8') as inf:
25-
md = inf.read()
26-
toc = TocExtension(baselevel=baselevel, slugify=lambda value, separator: prefix + markdown.extensions.headerid.slugify(value, separator))
27-
outf.write(markdown.markdown(md, extensions=['markdown.extensions.tables', toc], output_format='html5', lazy_ol=False))
32+
mdown = inf.read()
33+
toc = TocExtension(
34+
baselevel=baselevel,
35+
slugify=(
36+
lambda value, separator:
37+
prefix + markdown.extensions.headerid.slugify(value, separator)
38+
)
39+
)
40+
outf.write(markdown.markdown(
41+
mdown, extensions=['markdown.extensions.tables', toc],
42+
output_format='html5', lazy_ol=False
43+
))
2844

29-
def maketoc(html_doc, toc):
45+
def _maketoc(html_doc, toc):
46+
"""Build table of contents."""
3047
parser = etree.HTMLParser()
3148
doc = etree.parse(html_doc, parser)
3249
last = -1
@@ -61,20 +78,22 @@ def maketoc(html_doc, toc):
6178
level -= 1
6279
toc.write(u'</nav>\n')
6380

64-
def embed_style(html_file):
81+
def _embed_style(html_file):
82+
"""Embed a CSS file in the HTML."""
6583
parser = etree.HTMLParser(encoding='utf-8')
6684
doc = etree.parse(html_file, parser)
6785
for node in doc.xpath('//link[@rel="stylesheet"]'):
6886
href = node.get('href')
69-
css = os.path.join(basepath, href)
87+
css = os.path.join(BASEPATH, href)
7088
node.tag = 'style'
7189
node.text = '\n' + open(css, 'r').read() + '\n '
7290
node.attrib.clear()
7391
node.set('id', href)
7492
with open(html_file, 'w') as f:
7593
f.write(etree.tostring(doc, method="html").decode('utf-8'))
7694

77-
def get_options(html_file):
95+
def _get_options(html_file):
96+
"""Get the next command-line option."""
7897
parser = etree.HTMLParser(encoding='utf-8')
7998
doc = etree.parse(html_file, parser)
8099
output = []
@@ -95,55 +114,61 @@ def get_options(html_file):
95114
output.append(node)
96115
return output
97116

98-
def embed_options(html_file):
117+
def _embed_options(html_file):
118+
"""Build the synopsis of command-line options."""
99119
parser = etree.HTMLParser(encoding='utf-8')
100120
doc = etree.parse(html_file, parser)
101121
for node in doc.xpath('//span[@id="placeholder-options"]'):
102122
node.clear()
103-
for c in get_options(html_file):
104-
node.append(c)
105-
with open(html_file, 'w') as f:
106-
f.write(etree.tostring(doc, method="html").decode('utf-8'))
123+
node.extend(_option for _option in _get_options(html_file))
124+
with open(html_file, 'w') as htmlf:
125+
htmlf.write(etree.tostring(doc, method='html').decode('utf-8'))
107126

108127
def makedoc(header=None, output=None, embedded_style=True):
109-
header = header or basepath + '/header.html'
110-
output = output or basepath + '/../doc/PC-BASIC_documentation.html'
128+
"""Build HTML documentation from sources."""
129+
header = header or BASEPATH + '/header.html'
130+
output = output or BASEPATH + '/../doc/PC-BASIC_documentation.html'
111131
try:
112-
os.mkdir(basepath + '/../doc')
132+
os.mkdir(BASEPATH + '/../doc')
113133
except OSError:
114134
# already there, ignore
115135
pass
116136
basic_license_stream = StringIO()
117137
doc_license_stream = StringIO()
118138
readme_stream = StringIO()
119139
ack_stream = StringIO()
120-
mdtohtml(basepath + '/../LICENSE.md', basic_license_stream)
121-
mdtohtml(basepath + '/LICENSE.md', doc_license_stream)
122-
mdtohtml(basepath + '/../README.md', readme_stream, baselevel=0)
123-
mdtohtml(basepath + '/../THANKS.md', ack_stream, 'acks_')
140+
_md_to_html(BASEPATH + '/../LICENSE.md', basic_license_stream)
141+
_md_to_html(BASEPATH + '/LICENSE.md', doc_license_stream)
142+
_md_to_html(BASEPATH + '/../README.md', readme_stream, baselevel=0)
143+
_md_to_html(BASEPATH + '/../THANKS.md', ack_stream, 'acks_')
124144

125145
# get the quick-start guide out of README
126146
quickstart = u''.join(readme_stream.getvalue().split(u'<hr>')[1:])
127147
quickstart = quickstart.replace(u'http://pc-basic.org/doc/2.0#', u'#')
128148

129149
quickstart_html = ('<article>\n' + quickstart + '</article>\n')
130-
licenses_html = '<footer>\n<h2 id="licence">Licences</h2>\n' + basic_license_stream.getvalue() + '<hr />\n' + doc_license_stream.getvalue() + '\n</footer>\n'
150+
licenses_html = (
151+
'<footer>\n<h2 id="licence">Licences</h2>\n' + basic_license_stream.getvalue()
152+
+ '<hr />\n' + doc_license_stream.getvalue() + '\n</footer>\n'
153+
)
131154
major_version = '.'.join(VERSION.split('.')[:2])
132155
settings_html = (
133-
'<article>\n' + open(basepath + '/settings.html', 'r').read().replace('0.0', major_version)
134-
+ '<hr />\n' + open(basepath + '/options.html', 'r').read()
135-
+ open(basepath + '/examples.html', 'r').read() + '</article>\n')
156+
'<article>\n'
157+
+ open(BASEPATH + '/settings.html', 'r').read().replace('0.0', major_version)
158+
+ '<hr />\n' + open(BASEPATH + '/options.html', 'r').read()
159+
+ open(BASEPATH + '/examples.html', 'r').read() + '</article>\n'
160+
)
136161
predoc = StringIO()
137162
predoc.write(quickstart_html)
138-
predoc.write(open(basepath + '/documentation.html', 'r').read())
163+
predoc.write(open(BASEPATH + '/documentation.html', 'r').read())
139164
predoc.write(settings_html)
140-
predoc.write(open(basepath + '/guide.html', 'r').read())
141-
predoc.write(open(basepath + '/reference.html', 'r').read())
142-
predoc.write(open(basepath + '/techref.html', 'r').read())
143-
predoc.write(open(basepath + '/devguide.html', 'r').read())
165+
predoc.write(open(BASEPATH + '/guide.html', 'r').read())
166+
predoc.write(open(BASEPATH + '/reference.html', 'r').read())
167+
predoc.write(open(BASEPATH + '/techref.html', 'r').read())
168+
predoc.write(open(BASEPATH + '/devguide.html', 'r').read())
144169
predoc.write('<article>\n' + ack_stream.getvalue() + '</article>\n')
145170
predoc.write(licenses_html)
146-
predoc.write(open(basepath + '/footer.html', 'r').read())
171+
predoc.write(open(BASEPATH + '/footer.html', 'r').read())
147172
predoc.seek(0)
148173
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
149174
if embedded_style:
@@ -152,7 +177,7 @@ def makedoc(header=None, output=None, embedded_style=True):
152177
<h1>PC-BASIC documentation</h1>
153178
<small>Version {0}</small>
154179
</header>
155-
""".format(VERSION, now, DESCRIPTION, LONG_DESCRIPTION)
180+
""".format(VERSION)
156181
else:
157182
subheader_html = u''
158183
subheader_html += u"""
@@ -178,7 +203,7 @@ def makedoc(header=None, output=None, embedded_style=True):
178203
<li><strong><a href="#dev">Developer's Guide</a></strong>, using PC-BASIC as a Python module</li>
179204
</ul>
180205
181-
""".format(VERSION, now, DESCRIPTION, LONG_DESCRIPTION)
206+
""".format(VERSION, now, SETUP_DATA['description'], SETUP_DATA['long_description'])
182207
if not embedded_style:
183208
subheader_html += u"""
184209
<p>
@@ -203,13 +228,13 @@ def makedoc(header=None, output=None, embedded_style=True):
203228
tocdoc.write(predoc.getvalue())
204229
tocdoc.seek(0)
205230
toc = StringIO()
206-
maketoc(tocdoc, toc)
231+
_maketoc(tocdoc, toc)
207232
header_html = open(header, 'r').read()
208233
with open(output, 'w') as outf:
209234
outf.write(header_html)
210235
outf.write(subheader_html)
211236
outf.write(toc.getvalue())
212237
outf.write(predoc.getvalue())
213-
embed_options(output)
238+
_embed_options(output)
214239
if embedded_style:
215-
embed_style(output)
240+
_embed_style(output)

0 commit comments

Comments
 (0)