GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — New Code Generator strategy. Implement the CodeGenerator ABC, rather · JavaScriptBach/stone@d238928

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .gitignore
  • README.rst
  • babelapi
    • __init__.py
    • api.py
    • babel
      • __init__.py
      • lexer.py
      • parser.py
      • tower.py
    • cli.py
    • compiler.py
    • data_type.py
    • generator
      • __init__.py
      • generator.py
      • jinja.py
    • lang
      • __init__.py
      • js.py
      • lang.py
      • python.py
      • ruby.py
    • segmentation.py
  • example
    • api
      • dbx-core-old
        • internal_min.py
        • v1.babel
        • v1_common.babelh
        • v2_common.babelh
        • v2_files.babel
        • v2_users.babel
      • dbx-core
        • files.babel
        • users.babel
    • template
      • docs
        • docs.babelt.html
        • docs.html
      • dropbox-python-sdk
        • base_files.py
        • base_namespace.babelt.py
        • base_users.py
        • client.babelt.py
        • client.py
      • dropbox-ruby-sdk
        • client.babelt.rb
        • client.rb
        • objects.babelt.rb
        • objects.rb
      • server-asp
        • asp.babelt.py
      • server
        • v2_server.babelt.py
        • v2_server.py
  • setup.py
  • test
    • test_babel.py
    • test_babel_internal.py

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.gitignore‎

Copy file name to clipboardExpand all lines: .gitignore
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ parsetab.py
88
/build
99
/dist
1010
/MANIFEST
11-
/babelsdk.egg-info
11+
/babelapi.egg-info
1212
/setuptools-3.1-py2.7.egg
1313
/setuptools-3.1.zip
Collapse file

‎README.rst‎

Copy file name to clipboardExpand all lines: README.rst
+10-10Lines changed: 10 additions & 10 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
****************
2-
BabelSDK
2+
BabelAPI
33
****************
44

55
Define an API once in Babel. Use templates to define how the Babel definition
@@ -31,22 +31,22 @@ Download or clone BabelSDK, and run the following in its root directory::
3131

3232
$ sudo python setup.py install
3333

34-
This will install a script ``babelsdk`` to your PATH that can be run from the
34+
This will install a script ``babelapi`` to your PATH that can be run from the
3535
command line::
3636

37-
$ babelsdk -h
37+
$ babelapi -h
3838

3939
If you did not run ``setup.py`` but have the Python package in your PYTHONPATH,
40-
you can replace ``babelsdk`` with ``python -m babelsdk.cli`` as follows::
40+
you can replace ``babelapi`` with ``python -m babelapi.cli`` as follows::
4141

42-
$ python -m babelsdk.cli -h
42+
$ python -m babelapi.cli -h
4343

4444
Simple Example
4545
--------------
4646

4747
You can compile an example babel and apply it to a documentation template::
4848

49-
$ babelsdk example/api/v2_files.babel example/api/v2_users.babel example/template/docs
49+
$ babelapi example/api/v2_files.babel example/api/v2_users.babel example/template/docs
5050

5151
You can view the generated documentation using::
5252

@@ -432,12 +432,12 @@ template must satisfy the following conditions:
432432
* IDEs that use the outer extension to determine syntax highlighting
433433
will continue to work.
434434

435-
2. The first line of the file must include ``babelsdk(jinja2)``.
435+
2. The first line of the file must include ``babelapi(jinja2)``.
436436

437437
* You'll want to make the first line a comment in the target language.
438438

439-
* ``# babelsdk(jinja2)`` for Python
440-
* ``<!-- babelsdk(jinja2) -->`` for HTML
439+
* ``# babelapi(jinja2)`` for Python
440+
* ``<!-- babelapi(jinja2) -->`` for HTML
441441

442442
* jinja2 is currently the only available generator. But, this allows for
443443
a pluggable architecture for templating engines.
@@ -447,7 +447,7 @@ Jinja2 Templating
447447

448448
You'll want to familiarize yourself with templating in
449449
`jinja2 <http://jinja.pocoo.org/docs/>`_. Your template will have access to the
450-
``api`` variable, which maps to the ``babelsdk.api.Api`` object. From this
450+
``api`` variable, which maps to the ``babelapi.api.Api`` object. From this
451451
object, you can access all the defined namespaces, data types, and operations.
452452
See the Python object definition for more information.
453453

Collapse file

‎babelsdk/__init__.py‎ ‎babelapi/__init__.py‎babelsdk/__init__.py renamed to babelapi/__init__.py

Copy file name to clipboard
File renamed without changes.
Collapse file

‎babelsdk/api.py‎ ‎babelapi/api.py‎babelsdk/api.py renamed to babelapi/api.py

Copy file name to clipboardExpand all lines: babelapi/api.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections import OrderedDict
22
from distutils.version import StrictVersion
33

4-
from babelsdk.data_type import Empty
4+
from babelapi.data_type import Empty
55

66
class Api(object):
77
"""
Collapse file

‎babelsdk/babel/__init__.py‎ ‎babelapi/babel/__init__.py‎babelsdk/babel/__init__.py renamed to babelapi/babel/__init__.py

Copy file name to clipboard
File renamed without changes.
Collapse file

‎babelsdk/babel/lexer.py‎ ‎babelapi/babel/lexer.py‎babelsdk/babel/lexer.py renamed to babelapi/babel/lexer.py

Copy file name to clipboardExpand all lines: babelapi/babel/lexer.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self):
2121
self.lex = None
2222
self.tokens_queue = None
2323
self.cur_indent = None
24-
self._logger = logging.getLogger('babelsdk.babel.lexer')
24+
self._logger = logging.getLogger('babelapi.babel.lexer')
2525
self.last_token = None
2626

2727
def input(self, file_data, **kwargs):
Collapse file

‎babelsdk/babel/parser.py‎ ‎babelapi/babel/parser.py‎babelsdk/babel/parser.py renamed to babelapi/babel/parser.py

Copy file name to clipboardExpand all lines: babelapi/babel/parser.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import ply.yacc as yacc
44

5-
from babelsdk.babel.lexer import BabelLexer, BabelNull
5+
from babelapi.babel.lexer import BabelLexer, BabelNull
66

77
class BabelOpDef(object):
88
def __init__(self, name, path=None):
@@ -161,7 +161,7 @@ def __init__(self, debug=False):
161161
self.debug = debug
162162
self.yacc = yacc.yacc(module=self, debug=self.debug, write_tables=self.debug)
163163
self.lexer = BabelLexer()
164-
self._logger = logging.getLogger('babelsdk.babel.parser')
164+
self._logger = logging.getLogger('babelapi.babel.parser')
165165

166166
def parse(self, data):
167167
return self.yacc.parse(data.lstrip(), lexer=self.lexer, debug=self.debug)
Collapse file

‎babelsdk/babel/tower.py‎ ‎babelapi/babel/tower.py‎babelsdk/babel/tower.py renamed to babelapi/babel/tower.py

Copy file name to clipboardExpand all lines: babelapi/babel/tower.py
+13-8Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import os
55
import sys
66

7-
from babelsdk.babel.parser import BabelParser
8-
from babelsdk.data_type import (
7+
from babelapi.babel.parser import BabelParser
8+
from babelapi.data_type import (
99
Binary,
1010
Boolean,
1111
Empty,
@@ -23,19 +23,19 @@
2323
UInt64,
2424
Union,
2525
)
26-
from babelsdk.api import (
26+
from babelapi.api import (
2727
Api,
2828
ApiOperation,
2929
)
30-
from babelsdk.babel.parser import (
30+
from babelapi.babel.parser import (
3131
BabelAlias,
3232
BabelInclude,
3333
BabelNamespace,
3434
BabelOpDef,
3535
BabelSymbol,
3636
BabelTypeDef,
3737
)
38-
from babelsdk.segmentation import (
38+
from babelapi.segmentation import (
3939
Segment,
4040
SegmentList,
4141
Segmentation,
@@ -67,7 +67,7 @@ def __init__(self, paths, version='0.1b1', debug=False):
6767
"""Creates a new tower of babel."""
6868

6969
self._debug = debug
70-
self._logger = logging.getLogger('babelsdk.dsl.tower')
70+
self._logger = logging.getLogger('babelapi.dsl.tower')
7171

7272
self.api = Api(version=version)
7373

@@ -140,7 +140,7 @@ def _create_type(self, env, item):
140140

141141
def _create_field(self, env, babel_field):
142142
"""
143-
Given a BabelField, returns a babelsdk.babel.tower.Field object.
143+
Given a BabelField, returns a babelapi.babel.tower.Field object.
144144
145145
A BabelField is composed of symbols. This function resolves symbols to
146146
objects that we've instantiated in the current environment. For example,
@@ -240,9 +240,14 @@ def add_to_api(self, path, desc):
240240
env,
241241
item.error_data_type_name,
242242
)
243+
if item.path:
244+
path = item.path.lstrip('/')
245+
else:
246+
# TODO: Split and add dashes
247+
path = item.name.lower()
243248
operation = ApiOperation(
244249
item.name,
245-
item.path or item.name,
250+
path,
246251
item.doc,
247252
request_segmentation,
248253
response_segmentation,
Collapse file

‎babelsdk/cli.py‎ ‎babelapi/cli.py‎babelsdk/cli.py renamed to babelapi/cli.py

Copy file name to clipboardExpand all lines: babelapi/cli.py
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
A command-line interface for BabelSDK.
2+
A command-line interface for BabelAPI.
33
"""
44

55
import argparse
@@ -8,13 +8,13 @@
88
import os
99
import sys
1010

11-
from babelsdk.compiler import Compiler
12-
from babelsdk.babel.tower import TowerOfBabel
11+
from babelapi.compiler import Compiler
12+
from babelapi.babel.tower import TowerOfBabel
1313

1414
def main():
1515
"""The entry point for the program."""
1616

17-
cmdline_parser = argparse.ArgumentParser(description='BabelSDK')
17+
cmdline_parser = argparse.ArgumentParser(description='BabelAPI')
1818
cmdline_parser.add_argument(
1919
'-v',
2020
'--verbose',
@@ -74,7 +74,7 @@ def main():
7474
)
7575
c.build()
7676

77-
if not sys.argv[0].endswith('babelsdk'):
77+
if not sys.argv[0].endswith('babelapi'):
7878
# If we aren't running from an entry_point, then return api to make it
7979
# easier to do debugging.
8080
return api
Collapse file

‎babelsdk/compiler.py‎ ‎babelapi/compiler.py‎babelsdk/compiler.py renamed to babelapi/compiler.py

Copy file name to clipboardExpand all lines: babelapi/compiler.py
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import re
77
import shutil
88

9-
from babelsdk.generator.generator import CodeGenerator
10-
from babelsdk.generator.jinja import Jinja2Generator
9+
from babelapi.generator.generator import CodeGenerator
10+
from babelapi.generator.jinja import Jinja2Generator
1111

1212
class UnknownGenerator(Exception): pass
1313
class MissingBabelPreamble(Exception): pass
@@ -18,7 +18,7 @@ class Compiler(object):
1818
languages.
1919
"""
2020

21-
first_line_re = re.compile('babelsdk\((?P<generator>\w+)\)')
21+
first_line_re = re.compile('babelapi\((?P<generator>\w+)\)')
2222
template_extension = '.babelt'
2323

2424
def __init__(self,
@@ -29,15 +29,15 @@ def __init__(self,
2929
"""
3030
Creates a Compiler.
3131
32-
:param babelsdk.api.Api api: A Babel description of the API.
32+
:param babelapi.api.Api api: A Babel description of the API.
3333
:param str source_path: Path to source to be converted.
3434
:param str build_path: Location to save compiled sources to. If None,
3535
source files are compiled into the same directories.
3636
:param bool clean_build: If True, the build_path is removed before
3737
source files are compiled into them.
3838
"""
3939

40-
self._logger = logging.getLogger('babelsdk.compiler')
40+
self._logger = logging.getLogger('babelapi.compiler')
4141

4242
self.api = api
4343
self.source_path = source_path
@@ -178,7 +178,7 @@ def _process_file(self, source_path, target_path):
178178

179179
# Inject "Generated by" message in place of the preamble
180180
new_first_line = first_line.replace(matches.group(0),
181-
'Generated by BabelSDK')
181+
'Generated by BabelAPI')
182182
rendered_contents = (new_first_line +
183183
rendered_contents[len(first_line):])
184184

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.