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

Python user documentation: fix code highlighting, use valid Nix expressions #23535

Closed
wants to merge 3 commits into from
Closed

Python user documentation: fix code highlighting, use valid Nix expressions #23535

wants to merge 3 commits into from

Conversation

alexeymuranov
Copy link
Contributor

Fix code syntax highlighting by specifying language in every code block and adding some context to Nix code blocks to make them valid expressions. Use the same markup style for all code blocks.

@mention-bot
Copy link

@alexeymuranov, thanks for your PR! By analyzing the history of the files in this pull request, we identified @FRidh, @globin and @bennofs to be potential reviewers.

};
{
# ...
toolz = buildPythonPackage rec{
Copy link
Contributor

Choose a reason for hiding this comment

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

While you're at it, you could add a space after the rec keyword, for cleaness! ❓

name = "toolz-${version}";
version = "0.7.4";

src = pkgs.fetchurl{
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here after fetchurl.


buildInputs = with self; [ pkgs.libxml2 pkgs.libxslt ];
buildInputs = with self; [ pkgs.libxml2 pkgs.libxslt ];
Copy link
Contributor

Choose a reason for hiding this comment

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

Why with self if you only use pkgs.<something>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I only reformatted the source. What is self?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure, but I think we don't need it at that location. Probably should ask one of the python guys in here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But this is Nix, not Python. I just don't know what self in Nix is. Nix manual does not mention it.

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I mean we should ask the python guys from nixpkgs to ensure that we can remove self here.

self is commonly used to refer to the attribute set currently in, so this would bring everything from the current set into the scope of the expression. But my guess is that we do not need it, as we do not refer to something from self, like self.somepackage, but rather to pkgs.somepackage - so bringing pkgs into scope like so:

with pkgs; [ libxml2 libxslt ];

would make more sense to me. But as said: I'm not into the python-packaging ecosystem that much, so I would say we need someone from the python packaging team to approve what I suggest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, but i suppose it is not necessary to fix everything in one go.


buildInputs = [ pkgs.fftw pkgs.fftwFloat pkgs.fftwLongDouble];
buildInputs = [ pkgs.fftw pkgs.fftwFloat pkgs.fftwLongDouble];
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we consider using with pkgs here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok.

Copy link
Member

Choose a reason for hiding this comment

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

One should try to avoid with because it can shadow other packages.

meta = {
homepage = http://twistedmatrix.com/;
description = "Twisted, an event-driven networking engine written in Python";
license = stdenv.lib.licenses.mit; };
Copy link
Contributor

Choose a reason for hiding this comment

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

Sure we need this closing };?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we don't, thanks.

Permission denied

This is a [known bug](https://github.com/pypa/setuptools/issues/130) in setuptools.
```
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure, but it could be that we need blank lines before and after code listings that are introduced with three back-ticks... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, i never leave a blank line if it is the same paragraph, it renders fine on GitHub, but possibly it is not correct Markdown...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find any mention of required blank lines before and after "fenced" code blocks, and both GitHub and https://stackedit.io/editor are rendering fine without.

Copy link
Member

Choose a reason for hiding this comment

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

Remember that this file is converted with pandoc to docbook.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried with http://pandoc.org/try/ , i do not see any issues.

# FIXME!
LDFLAGS="-L${pkgs.fftw.dev}/lib -L${pkgs.fftwFloat.out}/lib -L${pkgs.fftwLongDouble.out}/lib"
CFLAGS="-I${pkgs.fftw.dev}/include -I${pkgs.fftwFloat.dev}/include -I${pkgs.fftwLongDouble.dev}/include"
'';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@matthiasbeyer, @FRidh, what is actually supposed to be here?

Copy link
Member

Choose a reason for hiding this comment

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

exactly that. Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not even valid Nix.

Copy link
Member

Choose a reason for hiding this comment

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

and why not? Check python-packages.nix where it is used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FRidh
Copy link
Member

FRidh commented Mar 5, 2017 via email

@alexeymuranov
Copy link
Contributor Author

Sorry, i do not know where to look for the "latest version". Anyway, i see now that apparently it is

preConfigure = ''

that is missing, thanks.

@FRidh
Copy link
Member

FRidh commented Mar 5, 2017

Its not really missing. The way it is currently in the docs is valid as well.

@alexeymuranov
Copy link
Contributor Author

The way it is currently in the docs is not even valid Nix.

@matthiasbeyer
Copy link
Contributor

What you highlighted with your last commit is indeed valid nix. At least I fail to figure out what would be non-valid in there...

@alexeymuranov
Copy link
Contributor Author

I suppose that

{
  LDFLAGS="-L${pkgs.fftw.dev}/lib -L${pkgs.fftwFloat.out}/lib -L${pkgs.fftwLongDouble.out}/lib"
  CFLAGS="-I${pkgs.fftw.dev}/include -I${pkgs.fftwFloat.dev}/include -I${pkgs.fftwLongDouble.dev}/include"
  '';
}

is then also valid Nix, right?

@matthiasbeyer
Copy link
Contributor

Ah, now I see what you mean... Yep, sorry, this is not valid Nix, you are right!

@FRidh
Copy link
Member

FRidh commented Mar 5, 2017

Indeed, that would give a syntax error.

@alexeymuranov
Copy link
Contributor Author

Yes, and for a good reason. Should i add preConfigure = '' or remove ''; and add a ;? (I am not sure.)

@FRidh
Copy link
Member

FRidh commented Mar 5, 2017

The former would have the preference.

Fix code syntax highlighting by specifying language in every code block
and adding some context to Nix code blocks to make them valid
expressions.  Use the same markup style for all code blocks.  Reformat
some code blocks.
@Mic92 Mic92 closed this in 34afc31 Mar 6, 2017
Mic92 pushed a commit that referenced this pull request Mar 6, 2017
Fix code syntax highlighting by specifying language in every code block
and adding some context to Nix code blocks to make them valid
expressions.  Use the same markup style for all code blocks.  Reformat
some code blocks.

fixes #23535

(cherry picked from commit 34afc31)
@alexeymuranov alexeymuranov deleted the python-user-documentation branch March 6, 2017 17:16
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.

None yet

5 participants