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

nitx: use doc commands #2591

Merged
merged 6 commits into from
Dec 19, 2017
Merged

nitx: use doc commands #2591

merged 6 commits into from
Dec 19, 2017

Conversation

Morriar
Copy link
Member

@Morriar Morriar commented Nov 28, 2017

Three things in this PR:

  • nitx now uses doc-commands (and related cleaning), bye bye the heavy DocModel with pre built DocPages
  • More tests for nitx
  • Move nitx to the doc tools suite, the group is now known as doc::term

Copy link
Member

@privat privat left a comment

Choose a reason for hiding this comment

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

this is so great!


redef class MEntity

# ASCII icon to be displayed in front of the entity
Copy link
Member

Choose a reason for hiding this comment

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

no unicode 😞 ?

i += 1
var line = fr.read_line
if i < location.line_start or i > location.line_end then continue
# FIXME add nitlight for console
Copy link
Member

Choose a reason for hiding this comment

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

console nitlight might be a good idea.

fun cs_source_code: String do
var file = location.file
if file == null then return ""
var fr = new FileReader.open(file.filename)
Copy link
Member

Choose a reason for hiding this comment

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

the source in in the location. why not ask for it? Location::text


redef class MDoc
# Returns the full comment formatted for the console
fun cs_comment(no_color: nullable Bool, indent: nullable Int): String do
Copy link
Member

Choose a reason for hiding this comment

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

a lot of your function have a no_color parameter. I'm worrying that someday you may want to add more options/flag.
What about having a single config parameter where you can add more flags/option, and even delegate some services?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's refactor it when needed.

for line in content do
res.append "{" " * indent}{line}\n"
end
if no_color == null or not no_color then
Copy link
Member

Choose a reason for hiding this comment

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

alternative nullable bool patterns are:

  • if no_color == true then but is weird because the nullness is not explicit and that makes the test looks like a truism
  • if no_color or else true then is nice because we do not repeat the no_color and the behavior of the null case is explicit, but a or else in a if might be confusing to some

Copy link
Member Author

Choose a reason for hiding this comment

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

I used all three alternatives in different projects. I still not sure of my favorite.

So I left it as it is.

if not mparameters.is_empty then
tpl.append "("
for i in [0..mparameters.length[ do
tpl.append mparameters[i].cs_signature
Copy link
Member

Choose a reason for hiding this comment

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

a (no_color) seems missing

@Morriar Morriar changed the title nix: use doc commands nitx: use doc commands Dec 1, 2017
@Morriar
Copy link
Member Author

Morriar commented Dec 1, 2017

reroll:

  • man page
  • added readline

@privat
Copy link
Member

privat commented Dec 4, 2017

  • manpages require the same short description than the option (is consistency a documentation quality?)
  • one test still fails

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
@Morriar
Copy link
Member Author

Morriar commented Dec 8, 2017

Reroll:

  • fixed tests (again)
  • fixed man (again)
  • added support for the new highlight to ansi

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
privat added a commit that referenced this pull request Dec 19, 2017
Three things in this PR:
* `nitx` now uses doc-commands (and related cleaning), bye bye the heavy `DocModel` with pre built `DocPages`
* More tests for `nitx`
* Move `nitx` to the `doc` tools suite, the group is now known as `doc::term`

Pull-Request: #2591
Reviewed-by: Jean Privat <jean@pryen.org>
@privat privat merged commit 85de593 into nitlang:master Dec 19, 2017
@Morriar Morriar deleted the nitx-commands branch December 19, 2017 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants