Commit cdcf451e authored by Fabrice Salvaire's avatar Fabrice Salvaire

enabled pyterate

parent ec1f3fc5
......@@ -3,6 +3,7 @@ __pycache__
doc/sphinx/build/
doc/sphinx/source/api/
doc/sphinx/source/examples/
lextab.py
parser.out
......
#?##################################################################################################
#?#
#?# PythonicGcodeMachine - @licence_header_description@
#?# Copyright (C) 2018 Fabrice Salvaire
#?#
#?# This program is free software: you can redistribute it and/or modify
#?# it under the terms of the GNU General Public License as published by
#?# the Free Software Foundation, either version 3 of the License, or
#?# (at your option) any later version.
#?#
#?# This program is distributed in the hope that it will be useful,
#?# but WITHOUT ANY WARRANTY; without even the implied warranty of
#?# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#?# GNU General Public License for more details.
#?#
#?# You should have received a copy of the GNU General Public License
#?# along with this program. If not, see <http://www.gnu.org/licenses/>.
#?#
#?##################################################################################################
####################################################################################################
"""Example to show how to annote a G-code program.
"""
#r#
#r# ==================================================
#r# Example to show how to annotate a G-code program
#r# ==================================================
#r#
####################################################################################################
......@@ -13,7 +36,7 @@ from PythonicGcodeMachine.Gcode.Rs274 import GcodeParser, gcodes, letters
program_filename = 'mill-example-1.ngc'
programs_directory = Path(__file__).parent.joinpath('programs')
programs_directory = Path(__file__).parents[1].joinpath('programs')
program_path = programs_directory.joinpath(program_filename)
with open(program_path, 'r') as fh:
lines = fh.readlines()
......@@ -26,7 +49,8 @@ program = parser.parse_lines(lines)
meaning_format = ' {:5}: {}'
for line in program:
print()
print(line.ansi_str())
# print(line.ansi_str()) # Fixme: pyterate
print(str(line))
for word in line.iter_on_word():
if word.letter in 'GM':
meaning = gcodes[str(word)].meaning
......@@ -35,3 +59,4 @@ for line in program:
letter = word.letter
meaning = letters[letter].meaning
print(meaning_format.format(letter, meaning))
#o#
.. -*- Mode: rst -*-
.. _examples-page:
==========
Examples
==========
#! /usr/bin/bash
# Regenerate from scratch
# examples=doc/sphinx/source/examples
# rm -rf ${examples}
echo
echo Generate RST examples files
MusicaLogLevel=WARNING pyterate # --force
echo
echo Run Sphinx
pushd doc/sphinx/
./make-html # --clean
popd
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment