Question about the spec and global section functors In "points in algebraic geometry why shift from m-spec to spec", Anton said that the global sections functor $\Gamma: \mathrm{LRSp} \to \mathrm{CRing}$ is left adjoint to the Spec functor $\mathrm{Spec}:\mathrm{CRing } \to \mathrm{LRSp}$, where $\mathrm{LRSp}$ is the category of locally ringed spaces. 
It is an exercise in Hartshorne (II 2.4) to show that this is true when $\mathrm{LRSp}$ is replaced with the category of schemes. I can solve this exercise, but my argument relies heavily on being able to cover a scheme with open affine schemes.
Can anyone point me towards a reference where this is proved or give me some hints?
 A: I just sum up the well-known construction: If $X$ is a locally ringed space, then define $f : X \to \text{Spec}(\Gamma(X,\mathcal{O}_X))$ as follows:
For every $x \in X$, let $f(x)$ be the kernel of the canonical homomorphism $\Gamma(X,\mathcal{O}_X) \to \kappa(x), s \mapsto s(x)$. This defines $f$ as a map. Remark that the preimage of the basic-open subset $D(s)$ is $X_s$, which is open. There is a canonical homomorphism $\Gamma(X,\mathcal{O}_X)_s \to \Gamma(X_s,\mathcal{O}_X)$ which extends the restriction map. This defines the algebraic portion of $f$. So basically $f$ is just "evaluation".
Besides we have an isomorphism $\Gamma(\text{Spec}(R),\mathcal{O}) \cong R$. It is easy to verify the two triangular identities, so we have an adjunction between the oppositve category of rings and the category of locally ringed spaces.
A: Thanks for the answers!
The theorem is actually Lemma 01I1 in the Stacks Project. I should have checked their before asking....
A: EGA 1 (Springer edition), proposition (1.6.3).
