Skip to content

Commit

Permalink
Merge pull request #14 from cgay/dev
Browse files Browse the repository at this point in the history
Incompatible change for lowercase? and uppercase?
  • Loading branch information
cgay authored Aug 6, 2023
2 parents 5e39e9a + b5f5d15 commit dccd106
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 153 deletions.
36 changes: 3 additions & 33 deletions documentation/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

import os
import sys

sys.path.insert(0, os.path.abspath('../../_packages/sphinx-extensions/current/src/sphinxcontrib'))

import dylan.domain
import dylan.themes as dylan_themes

# -- Project information -----------------------------------------------------

Expand All @@ -25,7 +15,7 @@
author = 'Carl Gay'

# The full version, including alpha/beta/rc tags
release = 'v1.2.0'
release = 'v2.0.0'


# -- General configuration ---------------------------------------------------
Expand All @@ -38,9 +28,6 @@
'sphinx.ext.intersphinx'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
Expand All @@ -52,22 +39,5 @@
# without depending on this top-level config file.
primary_domain = 'dylan'


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = dylan_themes.get_html_theme_default()

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = dylan_themes.get_html_theme_options_default()

# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = [dylan_themes.get_html_theme_path()]

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# sudo pip install -U furo
html_theme = 'furo'
100 changes: 16 additions & 84 deletions documentation/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ The *strings* library was originally defined in `DEP-0004
<http://opendylan.org/proposals/dep-0004.html>`_. Some additional background
material can be found there.

.. contents:: Contents
:local:
.. toctree::
:hidden:

.. note::

Expand Down Expand Up @@ -671,55 +671,20 @@ Case Conversion Functions
lowercase!("Hack Dylan!")
=> error, attempt to modify a string constant
.. generic-function:: lowercase?
:sealed:
.. function:: lowercase?

Returns :drm:`#t` if the argument is entirely composed of
non-uppercase characters.

:signature: lowercase? (string-or-character) => (is-lowercase?)
:parameter string-or-character: An instance of ``type-union(<string>, <character>)``.
:value is-lowercase?: An instance of :drm:`<boolean>`.

.. method:: lowercase?
:specializer: <character>
:sealed:

Returns :drm:`#t` if the given character is not an uppercase alphabetic.
Otherwise :drm:`#f` is returned.
Returns :drm:`#t` if the argument is a lowercase alphabetic character.
Otherwise returns :drm:`#f`.

:signature: lowercase? (character) => (is-lowercase?)
:parameter character: An instance of :drm:`<character>`.
:value is-lowercase?: An instance of :drm:`<boolean>`.
:example:

.. code-block:: dylan

lowercase?('n') => #t
lowercase?('N') => #f
lowercase?('*') => #t
.. method:: lowercase?
:specializer: <string>
:sealed:

Returns :drm:`#t` if the argument does not contain any uppercase
alphabetic characters. Otherwise :drm:`#f` is returned.

:signature: lowercase? (string) => (is-lowercase?)
:parameter string: An instance of :drm:`<string>`.
:parameter #key start: An instance of :drm:`<integer>`, default 0. The index
at which to start checking.
:parameter #key end: An instance of :drm:`<integer>`, default
``string.size``. The index before which to stop checking.
:value is-lowercase?: An instance of :drm:`<boolean>`.
:example:

.. code-block:: dylan
.. code-block:: dylan
lowercase?("Why me?") => #f
lowercase?("Why me?", start: 1) => #t
lowercase?("e.e. cummings") => #t
lowercase?('n') => #t
lowercase?('N') => #f
lowercase?('*') => #f
.. generic-function:: uppercase
:sealed:
Expand Down Expand Up @@ -820,54 +785,21 @@ Case Conversion Functions
uppercase!("Hack Dylan!")
=> error, attempt to modify a string constant
.. generic-function:: uppercase?
:sealed:

Returns :drm:`#t` if the argument is entirely composed of
non-lowercase characters.

:signature: uppercase? (string-or-character) => (is-uppercase?)
:parameter string-or-character: An instance of ``type-union(<string>, <character>)``.
:value is-uppercase?: An instance of :drm:`<boolean>`.
.. function:: uppercase?

.. method:: uppercase?
:specializer: <character>
:sealed:

Returns :drm:`#t` if the given character is not a lowercase alphabetic.
Otherwise :drm:`#f` is returned.
Returns :drm:`#t` if the argument is an uppercase alphabetic character.
Otherwise returns :drm:`#f`.

:signature: uppercase? (character) => (is-uppercase?)
:parameter character: An instance of :drm:`<character>`.
:value is-uppercase?: An instance of :drm:`<boolean>`.
:example:

.. code-block:: dylan
uppercase?('T') => #t
uppercase?('t') => #f
uppercase?('^') => #t
.. method:: uppercase?
:specializer: <string>
:sealed:

Returns :drm:`#t` if the argument does not contain any lowercase
alphabetic characters. Otherwise :drm:`#f` is returned.

:signature: uppercase? (string) => (is-uppercase?)
:parameter string: An instance of :drm:`<string>`.
:parameter #key start: An instance of :drm:`<integer>`, default 0. The index
at which to start checking.
:parameter #key end: An instance of :drm:`<integer>`, default
``string.size``. The index before which to stop checking.
:value is-uppercase?: An instance of :drm:`<boolean>`.
:example:
.. code-block:: dylan
.. code-block:: dylan
uppercase?('T') => #t
uppercase?('t') => #f
uppercase?('^') => #f
uppercase?("AbC") => #f
uppercase?("ABC") => #t
Comparison Functions
--------------------
Expand Down
2 changes: 1 addition & 1 deletion dylan-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
],
"description": "String manipulation functions",
"name": "strings",
"version": "1.2.0",
"version": "2.0.0",
"url": "https://github.com/dylan-lang/strings"
}
34 changes: 6 additions & 28 deletions strings.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -129,43 +129,21 @@ define method whitespace?
end;


// Returns #t if the required argument could be a value returned from
// 'as-uppercase'. In other words, if the argument does NOT contain
// any lowercase characters.
define sealed generic uppercase?
(string-or-character :: <string-or-char>, #key) => (uppercase? :: <boolean>);
(char :: <character>) => (uppercase? :: <boolean>);

define inline method uppercase?
(char :: <character>, #key) => (b :: <boolean>)
~lowercase-code?(as(<integer>, char))
end;

define method uppercase?
(string :: <string>,
#key start :: <integer> = 0,
end: epos :: <integer> = string.size)
=> (b :: <boolean>)
%every?(uppercase?, string, start, epos)
(char :: <character>) => (b :: <boolean>)
uppercase-code?(as(<integer>, char))
end;


// Returns #t if the required argument could be a value returned from
// 'as-lowercase'. In other words, if the argument does NOT contain
// any uppercase characters.
define sealed generic lowercase?
(string-or-character :: <string-or-char>, #key) => (lowercase? :: <boolean>);
(char :: <character>) => (lowercase? :: <boolean>);

define inline method lowercase?
(char :: <character>, #key) => (b :: <boolean>)
~uppercase-code?(as(<integer>, char))
end;

define method lowercase?
(string :: <string>,
#key start :: <integer> = 0,
end: epos :: <integer> = string.size)
=> (b :: <boolean>)
%every?(lowercase?, string, start, epos)
(char :: <character>) => (b :: <boolean>)
lowercase-code?(as(<integer>, char))
end;


Expand Down
22 changes: 15 additions & 7 deletions tests/strings-test-suite.dylan
Original file line number Diff line number Diff line change
Expand Up @@ -405,16 +405,24 @@ end test;

define test test-lowercase? ()
check-true("a", lowercase?('a'));
check-true("b", lowercase?("abc-$#^^10"));
check-false("c", lowercase?('A'));
check-false("d", lowercase?("aBc-$#^^10"));
check-true("z", lowercase?('z'));
check-false("A", lowercase?('A'));
check-false("Z", lowercase?('Z'));
check-false("@", lowercase?('@'));
check-false("[", lowercase?('['));
check-false("`", lowercase?('`'));
check-false("{", lowercase?('{'));
end test;

define test test-uppercase? ()
check-true("a", uppercase?('X'));
check-true("b", uppercase?("ABC-$#^^10"));
check-false("c", uppercase?('b'));
check-false("d", uppercase?("aBc-$#^^10"));
check-true("A", uppercase?('A'));
check-true("Z", uppercase?('Z'));
check-false("a", uppercase?('a'));
check-false("z", uppercase?('z'));
check-false("@", uppercase?('@'));
check-false("[", uppercase?('['));
check-false("`", uppercase?('`'));
check-false("{", uppercase?('{'));
end test;


Expand Down

0 comments on commit dccd106

Please sign in to comment.