Skip to content

Commit ede6db6

Browse files
committed
Merge branch 'develop'
2 parents 9218900 + 5154bd2 commit ede6db6

349 files changed

Lines changed: 2942 additions & 61020 deletions

File tree

Some content is hidden

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

BUILD.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11

22

33
### Setting up a development environment for PC-BASIC
4-
These instructions cover the steps needed to install the development source of PC-BASIC and its dependencies. You can also follow them if you simply want to install PC-BASIC from the source repository on GitHub.
4+
These instructions cover the steps needed to install the development source of PC-BASIC and its dependencies.
55

6-
#### You won't need to read this file just to install PC-BASIC ####
7-
General installation instructions for PC-BASIC can be found in `README.md`.
8-
The instructions there cover the most common platforms and use cases.
6+
> #### You won't need to read this file just to install PC-BASIC ####
7+
> General installation instructions for PC-BASIC can be found in `README.md`.
8+
> The instructions there cover the most common platforms and use cases.
9+
> The instructions in this file are for developers only.
910
1011

1112
#### Dependencies ####
1213
The following packages are needed, recommended or optional when installing PC-BASIC:
1314

14-
| Package | OS | Status | Used for
15-
|-------------------------------------------------------------------------------|--------------------|--------------|----------------------------------------
16-
| [Python 3.6.9 or later](https://www.python.org/downloads/) | all | required |
17-
| [SDL2](https://www.libsdl.org/download-2.0.php) | all | recommended | graphics and sound with `--interface=graphical`
18-
| [PySerial 3.4](https://github.com/pyserial/pyserial) | all | optional | physical or emulated serial port access
19-
| [PyParallel](https://github.com/pyserial/pyparallel) | Windows, Linux | optional | physical parallel port access
20-
| [PyAudio](http://people.csail.mit.edu/hubert/pyaudio/) | all | optional | sound without SDL2
15+
| Package | Status | Used for
16+
|-------------------------------------------------------------------------------|----------------------------|----------------------------------------
17+
| [Python 3.6.9 or later](https://www.python.org/downloads/) | required |
18+
| [`importlib_resources`](https://pypi.python.org/pypi/importlib_resources) | required for Python <= 3.6 |
19+
| [SDL2](https://www.libsdl.org/download-2.0.php) | recommended | graphics and sound
20+
| [PySerial 3.4](https://github.com/pyserial/pyserial) | optional | physical or emulated serial port access
21+
| [PyParallel](https://github.com/pyserial/pyparallel) | optional | physical parallel port access
22+
| [PyAudio](http://people.csail.mit.edu/hubert/pyaudio/) | optional | sound without SDL2
2123

22-
`setuptools` and `pip` are included with Python.
2324
Once you have a working Python installation, most dependencies can be installed with `pip`:
2425

25-
pip3 install pysdl2-dll pyserial
26+
pip install pysdl2-dll pyserial
27+
28+
If `pip` is not included with your copy of Python, install it with `python -m ensurepip` or through your system's package manager.
2629

2730
For Windows, Mac, and Linux, it is recommended to use the SDL2 and SDL2-gfx libraries provided by the [pysdl2-dll](https://github.com/a-hurst/pysdl2-dll) package.
2831
Alternatively, you can get the library directly from [libsdl.org](https://www.libsdl.org/download-2.0.php).
@@ -64,7 +67,7 @@ The following additional packages and tools are used for development, testing an
6467
| [`wheel`](https://pypi.python.org/pypi/wheel) | all | packaging
6568
| [`twine`](https://pypi.python.org/pypi/twine) | all | packaging
6669
| [`toml`](https://pypi.python.org/pypi/toml) | all | packaging
67-
| [`Pillow`](https://python-pillow.org/) | all | packaging
70+
| [`pillow`](https://python-pillow.org/) | all | packaging
6871
| [`cx_Freeze` 6.11.1](https://pypi.org/project/cx_Freeze/) | Windows, MacOS | packaging
6972
| `dpkg` | Linux | packaging
7073
| `alien` | Linux | packaging
@@ -78,7 +81,7 @@ These are the steps to set up the local repository ready to run PC-BASIC:
7881

7982
2. Make pcbasic/data/USAGE.txt
8083

81-
python3.7 -m make docs
84+
python3.7 -m make local
8285

8386
3. Run pcbasic directly from the source directory
8487

@@ -88,8 +91,8 @@ These are the steps to set up the local repository ready to run PC-BASIC:
8891
#### Deprecation warnings ####
8992

9093
The following features are deprecated and **will be removed in the near future**:
91-
- Python 2.7 support
92-
- The [PyGame 1.9.3](www.pygame.org)-based interface
94+
- Support for end-of-life Python versions 2.7 and 3.6
95+
- The [PyGame](www.pygame.org)-based interface
9396
- The [curses](https://invisible-island.net/ncurses/)-based interface
9497
- The option `--utf8` (use `--text-encoding=utf8`)
9598
- The aliases `freedos`, `univga`, and `unifont` for the default font (use `--font=default`)

docs/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""
2+
PC-BASIC - docs
3+
Documentation builder and source
4+
5+
(c) 2013--2022 Rob Hagemans
6+
This file is released under the GNU GPL version 3 or later.
7+
"""
8+
9+
from .usage import make_usage
10+
from .man import make_man
11+
from .htmldoc import make_htmldoc

docsrc/doc.py renamed to docs/htmldoc.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
PC-BASIC - docsrc.doc
2+
PC-BASIC - docs.htmldoc
33
HTML documentation builder
44
55
(c) 2013--2022 Rob Hagemans
@@ -9,7 +9,7 @@
99
import os
1010
import json
1111
from datetime import datetime
12-
from io import StringIO, open
12+
from io import StringIO
1313

1414
from lxml import etree
1515
import markdown
@@ -19,8 +19,10 @@
1919

2020

2121
BASEPATH = os.path.dirname(os.path.realpath(__file__))
22+
SOURCE_PATH = os.path.join(BASEPATH, 'source')
2223

23-
with open(os.path.join(BASEPATH, 'description.json'), encoding='utf-8') as desc_json:
24+
25+
with open(os.path.join(SOURCE_PATH, 'description.json'), encoding='utf-8') as desc_json:
2426
DESCR_STRS = json.load(desc_json)
2527

2628

@@ -86,7 +88,7 @@ def _embed_style(html_file):
8688
doc = etree.parse(html_file, parser)
8789
for node in doc.xpath('//link[@rel="stylesheet"]'):
8890
href = node.get('href')
89-
css = os.path.join(BASEPATH, href)
91+
css = os.path.join(SOURCE_PATH, href)
9092
node.tag = 'style'
9193
node.text = '\n' + read_file(css) + '\n '
9294
node.attrib.clear()
@@ -126,21 +128,16 @@ def _embed_options(html_file):
126128
with open(html_file, 'w', encoding='utf-8') as htmlf:
127129
htmlf.write(etree.tostring(doc, method='html').decode('utf-8'))
128130

129-
def makedoc(header=None, output=None, embedded_style=True):
131+
def make_htmldoc(output_path, output_filename, *, header=None, embedded_style=True):
130132
"""Build HTML documentation from sources."""
131-
header = header or BASEPATH + '/header.html'
132-
output = output or BASEPATH + '/../doc/PC-BASIC_documentation.html'
133-
try:
134-
os.mkdir(BASEPATH + '/../doc')
135-
except OSError:
136-
# already there, ignore
137-
pass
133+
header = header or SOURCE_PATH + '/header.html'
134+
output = os.path.join(output_path, output_filename)
138135
basic_license_stream = StringIO()
139136
doc_license_stream = StringIO()
140137
readme_stream = StringIO()
141138
ack_stream = StringIO()
142139
_md_to_html(BASEPATH + '/../LICENSE.md', basic_license_stream)
143-
_md_to_html(BASEPATH + '/LICENSE.md', doc_license_stream)
140+
_md_to_html(SOURCE_PATH + '/LICENSE.md', doc_license_stream)
144141
_md_to_html(BASEPATH + '/../README.md', readme_stream, baselevel=0)
145142
_md_to_html(BASEPATH + '/../THANKS.md', ack_stream, 'acks_')
146143

@@ -156,21 +153,21 @@ def makedoc(header=None, output=None, embedded_style=True):
156153
major_version = '.'.join(VERSION.split('.')[:2])
157154
settings_html = (
158155
'<article>\n'
159-
+ read_file(BASEPATH + '/settings.html').replace('0.0', major_version)
160-
+ '<hr />\n' + read_file(BASEPATH + '/options.html')
161-
+ read_file(BASEPATH + '/examples.html') + '</article>\n'
156+
+ read_file(SOURCE_PATH + '/settings.html').replace('0.0', major_version)
157+
+ '<hr />\n' + read_file(SOURCE_PATH + '/options.html')
158+
+ read_file(SOURCE_PATH + '/examples.html') + '</article>\n'
162159
)
163160
predoc = StringIO()
164161
predoc.write(quickstart_html)
165-
predoc.write(read_file(BASEPATH + '/documentation.html'))
162+
predoc.write(read_file(SOURCE_PATH + '/documentation.html'))
166163
predoc.write(settings_html)
167-
predoc.write(read_file(BASEPATH + '/guide.html'))
168-
predoc.write(read_file(BASEPATH + '/reference.html'))
169-
predoc.write(read_file(BASEPATH + '/techref.html'))
170-
predoc.write(read_file(BASEPATH + '/devguide.html'))
164+
predoc.write(read_file(SOURCE_PATH + '/guide.html'))
165+
predoc.write(read_file(SOURCE_PATH + '/reference.html'))
166+
predoc.write(read_file(SOURCE_PATH + '/techref.html'))
167+
predoc.write(read_file(SOURCE_PATH + '/devguide.html'))
171168
predoc.write('<article>\n' + ack_stream.getvalue() + '</article>\n')
172169
predoc.write(licenses_html)
173-
predoc.write(read_file(BASEPATH + '/footer.html'))
170+
predoc.write(read_file(SOURCE_PATH + '/footer.html'))
174171
predoc.seek(0)
175172
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
176173
if embedded_style:

docsrc/man.py renamed to docs/man.py

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
PC-BASIC - docsrc.man
2+
PC-BASIC - docs.man
33
Manfile builder
44
55
(c) 2013--2022 Rob Hagemans
@@ -10,34 +10,44 @@
1010
import re
1111
import json
1212
import gzip
13-
from io import StringIO, open
13+
from io import StringIO
1414

1515
from lxml import etree
1616

1717

1818
# file locations
19-
BASEPATH = os.path.dirname(os.path.realpath(__file__))
20-
OPTIONS_HTML = os.path.join(BASEPATH, 'options.html')
21-
EXAMPLE_HTML = os.path.join(BASEPATH, 'examples.html')
22-
MORE_HTML = os.path.join(BASEPATH, 'moreman.html')
23-
DOC_PATH = os.path.join(BASEPATH, '..', 'doc')
24-
MAN_FILE = os.path.join(BASEPATH, '..', 'doc', 'pcbasic.1.gz')
19+
SOURCE_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'source')
20+
OPTIONS_HTML = os.path.join(SOURCE_PATH, 'options.html')
21+
EXAMPLE_HTML = os.path.join(SOURCE_PATH, 'examples.html')
22+
MORE_HTML = os.path.join(SOURCE_PATH, 'moreman.html')
2523

26-
# setup metadata
27-
with open(os.path.join(BASEPATH, 'description.json'), encoding='utf-8') as desc_json:
24+
# long and short descriptions
25+
with open(os.path.join(SOURCE_PATH, 'description.json'), encoding='utf-8') as desc_json:
2826
DESC_STRS = json.load(desc_json)
2927

3028

31-
TROFF_ESCAPES = [
32-
(u'\\', u'\\[rs]'), (u'-', u'\\-'), (u'|', u'\\||'),
33-
(u'.', u'\\|.'), (u'"', u'\\[dq]'), (u"'", u"\\|'"),
34-
]
29+
def make_man(man_path, man_name):
30+
"""Convert HTML sources to manfile."""
31+
title_html = '<h1>pcbasic</h1><p>%s</p>\n' % DESC_STRS['description']
32+
desc_html = '<h3>Description</h2><p>%s</p>\n' % DESC_STRS['long_description']
33+
options_html = open(OPTIONS_HTML).read()
34+
examples_html = open(EXAMPLE_HTML).read()
35+
more_html = open(MORE_HTML).read()
36+
man_html = ''.join((title_html, desc_html, options_html, examples_html, more_html))
37+
# output manfile
38+
man_file = os.path.join(man_path, man_name)
39+
with gzip.open(man_file, 'w') as man:
40+
man.write(_html_to_man(man_html).encode('utf-8'))
3541

3642

3743
def _text_to_man(text):
3844
"""Convert plain text to troff."""
3945
# escape special characters
40-
for key, value in TROFF_ESCAPES:
46+
troff_escapes = [
47+
(u'\\', u'\\[rs]'), (u'-', u'\\-'), (u'|', u'\\||'),
48+
(u'.', u'\\|.'), (u'"', u'\\[dq]'), (u"'", u"\\|'"),
49+
]
50+
for key, value in troff_escapes:
4151
text = text.replace(key, value)
4252
# replace line feeds with spaces
4353
text = text.replace(u'\n', u' ')
@@ -79,21 +89,3 @@ def _html_to_man(html):
7989
manpage = '\'\\" t\n.pc\n.TH PCBASIC 1\n' + _convert_element(docroot)
8090
# replace two starting spaces (not sure where from)
8191
return re.sub('\t +', '\t', re.sub('\n +', '\n', manpage))
82-
83-
84-
def makeman():
85-
"""Convert HTML sources to manfile."""
86-
title_html = '<h1>pcbasic</h1><p>%s</p>\n' % DESC_STRS['description']
87-
desc_html = '<h3>Description</h2><p>%s</p>\n' % DESC_STRS['long_description']
88-
options_html = open(OPTIONS_HTML).read()
89-
examples_html = open(EXAMPLE_HTML).read()
90-
more_html = open(MORE_HTML).read()
91-
man_html = ''.join((title_html, desc_html, options_html, examples_html, more_html))
92-
try:
93-
os.mkdir(DOC_PATH)
94-
except EnvironmentError:
95-
# already there, ignore
96-
pass
97-
# output manfile
98-
with gzip.open(MAN_FILE, 'w') as manfile:
99-
manfile.write(_html_to_man(man_html).encode('utf-8'))
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)