Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More languages #13

Merged
merged 24 commits into from Aug 12, 2020
Merged

Conversation

mattkatz
Copy link
Contributor

@mattkatz mattkatz commented Aug 5, 2020

Ensure that we output each language in a file per markdown document.

If there are multiple language blocks in one document, each goes to the right file.

If the language is python, output init.py package indicators along the output tree to a file.

Allow multiple language descriptions for markdown blocks to go to the same file extension ("csharp", "c#" and "cs" all output ".cs" files)

@mattkatz
Copy link
Contributor Author

mattkatz commented Aug 6, 2020

Not sure why this is showing conflicts as they seem really clearly one-sided.

mkcodes.py Show resolved Hide resolved
Matt Katz and others added 14 commits Aug 6, 2020
simple file writing is simpler with pathlib.Path.write_text

For make_directories, python2 is end of life. python3 doesn't require
blank __init__.py files, so we can rely on pathlib.path.mkdir
Python unittest discover still relies on __init__.py files and doesn't
support namespace packages. By default we can create these but allow for
their suppression if using other test frameworks.
If mkcodes supports many language blocks, we can make the default
language python. safe mode should remove that default and not output
languages that aren't specified.

2 tests not passing
rather than assume python, let's just recognize that's the default
language for unknown blocsk. People can override that as needed if they
want to put in some other assumptions.
as we pass through a document, get per-language codeblocks, then write
those out to the correct extensionfile. By default, everything is still
python - though it can be overridden
Now the default language is python
codeblocks in other languages can be broken out into their own language
files. There is a way to add more languages with mappings, but a
language fenced codeblock will default to use that language as the
output extension
Also remove some commented code, shorten comments
For non python paths, don't declare them to be python packages.
also conform new test to self.call
mkcodes.py Show resolved Hide resolved
@ryneeverett
Copy link
Owner

ryneeverett commented Aug 6, 2020

Not sure why this is showing conflicts as they seem really clearly one-sided.

I rebased on master.

mkcodes.py Outdated Show resolved Hide resolved
@ryneeverett
Copy link
Owner

ryneeverett commented Aug 7, 2020

I pushed some changes onto the rebase I did the other day. If you're going to push more to this branch you should pull first and then you wont re-push the conflicts.

ryneeverett added 2 commits Aug 9, 2020
The safety flag refers to whether a default language is used. This would
have made it also accept the previous language used, which doesn't seem
right.
mkcodes.py Outdated
def main(inputs, output, github, safe, package_python):
help='Add __init__.py files to python dirs for test discovery')
@click.option('--default_lang', default='py',
help='Assumed language for code blocks without language hits.')
Copy link
Owner

@ryneeverett ryneeverett Aug 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bit of dissonance between the --safe flag and the --default-lang option that we may want to resolve. Some ideas:

  • Perhaps the use of both of these flags should raise an error? (I'd imagine there's an option to indicate incompatible arguments in the click api.)
  • Perhaps we should remove the --safe flag in favor of --default_lang= (no value). Maybe --safe should just be an alias for --default_lang=.

Copy link
Contributor Author

@mattkatz mattkatz Aug 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure - I lean towards --safe == default_lang==None

the motivation for safe seems to be "ignore code blocks that don't have a language!
default_lang's motivation is "assume the language is this if you don't know".
If there is no language and you don't know what extension to use, I can't imagine a scenario where you want to output the codes.
If you have some directories where the language on unmarked codes is py and some directories where the default lang is elm, you can indicate that easily with multiple runs, one for each directory.

If you have a single file with multiple code blocks where you don't know the language, you really just need to get the document fixed to indicate the languages...

mkcodes.py Outdated Show resolved Hide resolved
@mattkatz
Copy link
Contributor Author

mattkatz commented Aug 9, 2020

I pushed some changes onto the rebase I did the other day. If you're going to push more to this branch you should pull first and then you wont re-push the conflicts.

Ok - I'm working off of a fork, so I'll figure that out. I think that just means doing a pull rebase from your master into my fork branch.

mkcodes.py Outdated Show resolved Hide resolved
mkcodes.py Outdated Show resolved Hide resolved
mkcodes.py Outdated Show resolved Hide resolved
tests/test.py Show resolved Hide resolved
@ryneeverett ryneeverett merged commit 16c8f9a into ryneeverett:master Aug 12, 2020
@ryneeverett
Copy link
Owner

ryneeverett commented Aug 12, 2020

This is a huge improvement, thanks for sticking with it!

@mattkatz
Copy link
Contributor Author

mattkatz commented Aug 15, 2020

Just checked into see the merge! Awesome! Feels great to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants