Skip to content

Instantly share code, notes, and snippets.

@hozumi
Created November 23, 2015 17:16
Show Gist options
  • Save hozumi/7669e5d8466a5013cd02 to your computer and use it in GitHub Desktop.
Save hozumi/7669e5d8466a5013cd02 to your computer and use it in GitHub Desktop.
site_name: My Docs
markdown_extensions:
tox:
slugify: !!python/object:myslugify.slugify
import re
import unicodedata
def slugify(value, separator):
""" Slugify a string, to make it URL friendly. """
normalized = unicodedata.normalize('NFKD', value)
try:
normalized.encode('ascii')
v = re.sub('[^\w\s-]', '', normalized).strip().lower()
except UnicodeEncodeError:
v = normalized
return re.sub('[%s\s]+' % separator, separator, v)
% pyenv global
3.4.3
% python --version
Python 3.4.3
% mkdocs --version
mkdocs, version 0.14.0
% ls
docs mkdocs.yml myslugify.py site
% PYTHONPATH=. mkdocs build
Traceback (most recent call last):
File "/Users/fatrow/.pyenv/versions/3.4.3/bin/mkdocs", line 11, in <module>
sys.exit(cli())
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/click/core.py", line 700, in __call__
return self.main(*args, **kwargs)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/click/core.py", line 680, in main
rv = self.invoke(ctx)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/click/core.py", line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/click/core.py", line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/click/core.py", line 508, in invoke
return callback(*args, **kwargs)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/mkdocs/cli.py", line 133, in build_command
site_dir=site_dir
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/mkdocs/config/base.py", line 143, in load_config
cfg.load_file(config_file)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/mkdocs/config/base.py", line 96, in load_file
return self.load_dict(utils.yaml_load(config_file))
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/mkdocs/utils/__init__.py", line 58, in yaml_load
return yaml.load(source, Loader)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/yaml/__init__.py", line 72, in load
return loader.get_single_data()
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/yaml/constructor.py", line 37, in get_single_data
return self.construct_document(node)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/yaml/constructor.py", line 46, in construct_document
for dummy in generator:
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/yaml/constructor.py", line 398, in construct_yaml_map
value = self.construct_mapping(node)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/yaml/constructor.py", line 204, in construct_mapping
return super().construct_mapping(node, deep=deep)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/yaml/constructor.py", line 129, in construct_mapping
value = self.construct_object(value_node, deep=deep)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/yaml/constructor.py", line 91, in construct_object
data = next(generator)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/yaml/constructor.py", line 575, in construct_python_object
instance = self.make_python_instance(suffix, node, newobj=True)
File "/Users/fatrow/.pyenv/versions/3.4.3/lib/python3.4/site-packages/yaml/constructor.py", line 556, in make_python_instance
return cls(*args, **kwds)
TypeError: slugify() missing 2 required positional arguments: 'value' and 'separator'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment